From c3879be19f1277f6641b6224b968b3d1d6453313 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sat, 10 Dec 2016 18:35:47 +0000 Subject: [PATCH] re PR fortran/78350 (ICE in gfc_code2string(): Bad code, at fortran/misc.c:193) 2016-12-10 Paul Thomas PR fortran/78350 * resolve.c (resolve_structure_cons): Remove the block that tried to remove a charlen and rely on namespace cleanup. From-SVN: r243517 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/resolve.c | 27 ++++----------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 795f1f2f2ee..42e0d61682a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-12-10 Paul Thomas + + PR fortran/78350 + * resolve.c (resolve_structure_cons): Remove the block that + tried to remove a charlen and rely on namespace cleanup. + 2016-12-09 Paul Thomas PR fortran/77903 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index d04b4318742..c7d872cb5b3 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1257,31 +1257,12 @@ resolve_structure_cons (gfc_expr *expr, int init) gfc_constructor_append_expr (&cons->expr->value.constructor, para, &cons->expr->where); } + if (cons->expr->expr_type == EXPR_ARRAY) { - gfc_constructor *p; - p = gfc_constructor_first (cons->expr->value.constructor); - if (cons->expr->ts.u.cl != p->expr->ts.u.cl) - { - gfc_charlen *cl, *cl2; - - cl2 = NULL; - for (cl = gfc_current_ns->cl_list; cl; cl = cl->next) - { - if (cl == cons->expr->ts.u.cl) - break; - cl2 = cl; - } - - gcc_assert (cl); - - if (cl2) - cl2->next = cl->next; - - gfc_free_expr (cl->length); - free (cl); - } - + /* Rely on the cleanup of the namespace to deal correctly with + the old charlen. (There was a block here that attempted to + remove the charlen but broke the chain in so doing.) */ cons->expr->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL); cons->expr->ts.u.cl->length_from_typespec = true; cons->expr->ts.u.cl->length = gfc_copy_expr (comp->ts.u.cl->length); -- 2.30.2