re PR fortran/78350 (ICE in gfc_code2string(): Bad code, at fortran/misc.c:193)
authorPaul Thomas <pault@gcc.gnu.org>
Sat, 10 Dec 2016 18:35:47 +0000 (18:35 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sat, 10 Dec 2016 18:35:47 +0000 (18:35 +0000)
2016-12-10 Paul Thomas  <pault@gcc.gnu.org>

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
gcc/fortran/resolve.c

index 795f1f2f2ee459518439211d6a6bbb5afbedd434..42e0d61682af77c7cae5926b347a78c86c95e0db 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-10 Paul Thomas  <pault@gcc.gnu.org>
+
+       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  <pault@gcc.gnu.org>
 
        PR fortran/77903
index d04b43187423aa9a81b5c4c383070dbb5cf32176..c7d872cb5b3391d07c3b3fdffc1d7fd79bd55709 100644 (file)
@@ -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);