re PR fortran/91944 (ICE in gfc_conv_array_initializer, at fortran/trans-array.c...
authorJakub Jelinek <jakub@redhat.com>
Wed, 27 Nov 2019 10:00:50 +0000 (11:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 27 Nov 2019 10:00:50 +0000 (11:00 +0100)
PR fortran/91944
* simplify.c (gfc_simplify_spread): Check gfc_init_expr_flag instead
of gfc_current_ns->sym_root->n.sym->attr.flavor == FL_PARAMETER.

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

From-SVN: r278762

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

index 25252501b1921dca16455665d475a59cf24703d8..4cf6e9e3d1a7518d1998199501e3c1baf0df93ea 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/91944
+       * simplify.c (gfc_simplify_spread): Check gfc_init_expr_flag instead
+       of gfc_current_ns->sym_root->n.sym->attr.flavor == FL_PARAMETER.
+
 2019-11-27  Tobias Burnus  <tobias@codesourcery.com>
 
        PR middle-end/92463
index b02c549ecff8b1a90e5fc8f072696e8f73a5fbc2..93f3da38af6075b5ba9e466db4457db40aed1478 100644 (file)
@@ -7656,7 +7656,7 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_exp
   nelem = mpz_get_si (size) * ncopies;
   if (nelem > flag_max_array_constructor)
     {
-      if (gfc_current_ns->sym_root->n.sym->attr.flavor == FL_PARAMETER)
+      if (gfc_init_expr_flag)
        {
          gfc_error ("The number of elements (%d) in the array constructor "
                     "at %L requires an increase of the allowed %d upper "
index ab455910c4df4a8c2e26e25a4bffdee3f71e713e..92d6855694b6b53ef822903963eb8b11a952e6b5 100644 (file)
@@ -1,5 +1,8 @@
 2019-11-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR fortran/91944
+       * gfortran.dg/spread_size_limit_2.f90: New test.
+
        PR c++/92524
        * g++.dg/cpp0x/pr92524.C: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/spread_size_limit_2.f90 b/gcc/testsuite/gfortran.dg/spread_size_limit_2.f90
new file mode 100644 (file)
index 0000000..3ea064e
--- /dev/null
@@ -0,0 +1,11 @@
+! PR fortran/91944
+! { dg-do compile }
+! { dg-options "-fmax-array-constructor=65535" }
+
+program pr91944
+  integer, parameter :: n = 10
+  integer, parameter :: m = 65536
+  integer :: i
+  integer :: x(n,m) = spread([(i,i=1,n)], dim=2, ncopies=m)    ! { dg-error "requires an increase of the allowed 65535 upper limit" }
+  print *, x(n,m)
+end