re PR fortran/78479 (ICE in gfc_apply_init, at fortran/expr.c:4135)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 22 Nov 2016 21:52:15 +0000 (21:52 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Tue, 22 Nov 2016 21:52:15 +0000 (21:52 +0000)
2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78479
* expr.c (gfc_apply_init):  Allocate a charlen if needed.

2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78479
* gfortran.dg/char_component_initializer_3.f90: New test.

From-SVN: r242725

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 [new file with mode: 0644]

index 48c533d1eaf4606502a5f8e632012f1afe76614f..1ea1c2cbc9f6edb59b81333f3d6000168afdc2c7 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78479
+       * expr.c (gfc_apply_init):  Allocate a charlen if needed.
+
 2016-11-22  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/78443
index e2d1311d1a5838e35a95b8f0fc020570954db314..b028d81ba6d07f37d1398ae32ddbb744c678052e 100644 (file)
@@ -4132,7 +4132,12 @@ gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init)
                 {
                   gfc_set_constant_character_len (len, ctor->expr,
                                                   has_ts ? -1 : first_len);
-                  ctor->expr->ts.u.cl->length = gfc_copy_expr (ts->u.cl->length);
+                 if (!ctor->expr->ts.u.cl)
+                   ctor->expr->ts.u.cl
+                     = gfc_new_charlen (gfc_current_ns, ts->u.cl);
+                 else
+                    ctor->expr->ts.u.cl->length
+                     = gfc_copy_expr (ts->u.cl->length);
                 }
             }
         }
index d18ad6dba08eafcea2759bdc7660a1c3e7d39fd9..bb5ce39e33d5bff2fdf9a27e0ddc8c582d63539b 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78479
+       * gfortran.dg/char_component_initializer_3.f90: New test.
+
 2016-11-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/78451
diff --git a/gcc/testsuite/gfortran.dg/char_component_initializer_3.f90 b/gcc/testsuite/gfortran.dg/char_component_initializer_3.f90
new file mode 100644 (file)
index 0000000..634da4a
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+program p
+   type t
+      character(3) :: c(1) = 'a' // ['b']
+   end type
+end