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 5e10387..3bd9743 100644 (file)
@@ -1,5 +1,11 @@
 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
        * simplify.c (gfc_simplify_spread): Issue error for too large array 
        constructor in a PARAMETER statement.
index d1c17f0..841e9e1 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 b820e13..8109c33 100644 (file)
@@ -1,5 +1,10 @@
 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
        * gfortran.dg/pr43996.f90: New test.
 
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