re PR fortran/32156 (ICE with characters)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 31 May 2007 21:12:10 +0000 (21:12 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 31 May 2007 21:12:10 +0000 (21:12 +0000)
2007-05-31  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/32156
* trans-array.c (gfc_trans_array_constructor): Treat the case
where the ss expression charlen is missing.

2007-05-31  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/32156
* gfortran.dg/char_array_constructor_3.f90: New test.

From-SVN: r125241

gcc/fortran/trans-array.c

index efff3fd..a923871 100644 (file)
@@ -1635,8 +1635,18 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss)
       if (!ss->string_length)
        gfc_todo_error ("complex character array constructors");
 
-      ss->expr->ts.cl->backend_decl = ss->string_length;
+      /* It is surprising but still possible to wind up with expressions that
+        lack a character length.
+        TODO Find the offending part of the front end and cure this properly.
+        Concatenation involving arrays is the main culprit.  */
+      if (!ss->expr->ts.cl)
+       {
+         ss->expr->ts.cl = gfc_get_charlen ();
+         ss->expr->ts.cl->next = gfc_current_ns->cl_list;
+         gfc_current_ns->cl_list = ss->expr->ts.cl->next;
+       }
 
+      ss->expr->ts.cl->backend_decl = ss->string_length;
 
       type = gfc_get_character_type_len (ss->expr->ts.kind, ss->string_length);
       if (const_string)