Message ID | db8f2678-f42b-cf1d-4663-a13a35382e39@tkoenig.net |
---|---|
State | New |
Headers | show |
Series | [fortran] Fix PR 85102, take 2 | expand |
On Mon, Apr 02, 2018 at 02:05:29PM +0200, Thomas König wrote: > + if (as->type == AS_EXPLICIT) > + { > + for (int i = 0; i < as->rank; i++) > + { > + gfc_expr *e, *n; > + e = as->lower[i]; > + if (e->expr_type != EXPR_CONSTANT) > + { > + n = gfc_copy_expr (e); > + gfc_simplify_expr (n, 1); > + if (n->expr_type == EXPR_CONSTANT) > + gfc_replace_expr (e, n); else gfc_free_expr (n); > + } > + e = as->upper[i]; > + if (e->expr_type != EXPR_CONSTANT) > + { > + n = gfc_copy_expr (e); > + gfc_simplify_expr (n, 1); > + if (n->expr_type == EXPR_CONSTANT) > + gfc_replace_expr (e, n); else gfc_free_expr (n); > + } > + } > + } Don't you need the above changes to avoid leaking memory?
Hi Steve, > else > gfc_free_expr (n); > > Don't you need the above changes to avoid leaking memory? Correct. OK with those changes? Regards Thomas
Index: decl.c =================================================================== --- decl.c (revision 258845) +++ decl.c (working copy) @@ -2424,6 +2424,29 @@ variable_decl (int elem) goto cleanup; } } + if (as->type == AS_EXPLICIT) + { + for (int i = 0; i < as->rank; i++) + { + gfc_expr *e, *n; + e = as->lower[i]; + if (e->expr_type != EXPR_CONSTANT) + { + n = gfc_copy_expr (e); + gfc_simplify_expr (n, 1); + if (n->expr_type == EXPR_CONSTANT) + gfc_replace_expr (e, n); + } + e = as->upper[i]; + if (e->expr_type != EXPR_CONSTANT) + { + n = gfc_copy_expr (e); + gfc_simplify_expr (n, 1); + if (n->expr_type == EXPR_CONSTANT) + gfc_replace_expr (e, n); + } + } + } } char_len = NULL;