re PR fortran/59910 (ICE in gfc_conv_array_initializer, at fortran/trans-array.c...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 18 Nov 2015 22:55:17 +0000 (22:55 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 18 Nov 2015 22:55:17 +0000 (22:55 +0000)
2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/59910
* primary.c (gfc_match_structure_constructor): Reduce a structure
constructor in a DATA statement.

2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/59910
* gfortran.dg/pr59910.f90: New test.

From-SVN: r230580

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

index 5e10387b8a03f6dd512d032d34116e0f8685ecd0..3bd9743468f2d1e9eb23125f1e96425cdf7b0b2b 100644 (file)
@@ -1,3 +1,9 @@
+2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/59910
+       * primary.c (gfc_match_structure_constructor): Reduce a structure
+       constructor in a DATA statement.
+
 2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/43996
index d1c17f00fee84a3623281c493176233a46eec7bf..841e9e18287dad8766198f5dda1ac29d7bec796d 100644 (file)
@@ -2722,6 +2722,12 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result)
       return MATCH_ERROR;
     }
 
+  /* If a structure constructor is in a DATA statement, then each entity
+     in the structure constructor must be a constant.  Try to reduce the
+     expression here.  */
+  if (gfc_in_match_data ())
+    gfc_reduce_init_expr (e);
   *result = e;
   return MATCH_YES;
 }
index b820e136246ab58e4ad073b01b02535b5979a8d3..8109c33cb4bd39bd283829fbe045ae0252277b26 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/59910
+       * gfortran.dg/pr59910.f90: New test.
+
 2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/43996
diff --git a/gcc/testsuite/gfortran.dg/pr59910.f90 b/gcc/testsuite/gfortran.dg/pr59910.f90
new file mode 100644 (file)
index 0000000..2b288e4
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/59910
+!
+program main
+  implicit none
+  type bar
+      integer :: limit(1)
+  end type
+  type (bar) :: testsuite
+  data testsuite / bar(reshape(source=[10],shape=[1])) /
+end