]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/59910 (ICE in gfc_conv_array_initializer, at fortran/trans...
authorDominique d'Humieres <dominiq@lps.ens.fr>
Fri, 14 Apr 2017 13:00:02 +0000 (15:00 +0200)
committerDominique d'Humieres <dominiq@gcc.gnu.org>
Fri, 14 Apr 2017 13:00:02 +0000 (15:00 +0200)
2017-04-14  Dominique d'Humieres  <dominiq@lps.ens.fr>

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

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

* gfortran.dg/pr59910.f90: New test.

From-SVN: r246929

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

index 9dc753b567c4e7a8ab634195161d2624ad9e2c40..30c90d3f60319d6bed7db2c51fe70cae7f40f168 100644 (file)
@@ -1,3 +1,13 @@
+2017-04-14  Dominique d'Humieres  <dominiq@lps.ens.fr>
+
+       Backport from trunk
+       2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/59910
+       PR fortran/80388
+       * primary.c (gfc_match_structure_constructor): Reduce a structure
+       constructor in a DATA statement.
+
 2017-02-07  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * trans-types.c (gfc_get_int_kind_from_width_isofortranen):  Choose
index 44b9901cf676f2a80b6e5f242f203f41a1f3379b..d2fe8bc0eac09b21c1564402b428358eb946ba7d 100644 (file)
@@ -2657,6 +2657,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 d65d1ab7c368598b9d5d0cf2c10cf2e680f3f7e2..1493a615d01b95d2a1de870216adca81caa400c1 100644 (file)
@@ -1,3 +1,12 @@
+2017-04-14  Dominique d'Humieres  <dominiq@lps.ens.fr>
+
+       Backport from trunk
+       2015-11-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/59910
+       PR fortran/80388
+       * gfortran.dg/pr59910.f90: New test.
+
 2017-04-11  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        Backport from GCC 6
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