aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index b25bcc0..f29b035 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -939,8 +939,13 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp,
gfc_set_constant_character_len (len, init, false);
else if (init->expr_type == EXPR_ARRAY)
{
- gfc_free_expr (init->ts.cl->length);
+ /* Build a new charlen to prevent simplification from
+ deleting the length before it is resolved. */
+ init->ts.cl = gfc_get_charlen ();
+ init->ts.cl->next = gfc_current_ns->cl_list;
+ gfc_current_ns->cl_list = sym->ts.cl;
init->ts.cl->length = gfc_copy_expr (sym->ts.cl->length);
+
for (p = init->value.constructor; p; p = p->next)
gfc_set_constant_character_len (len, p->expr, false);
}