[PATCH] Fix spread simplification in initializers (PR fortran/91944)

Jakub Jelinek jakub@redhat.com
Wed Nov 27 00:01:00 GMT 2019


Hi!

The following testcase started ICEing with my r241630 PR78026 fix.
Before we created a new namespace and the check gfc_simplify_spread did
happened to work during that, but it doesn't anymore.
I believe gfc_init_expr_flag is the right flag to use when checking if
something has to be folded at compile time and we can't defer it to runtime
expansion.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

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

--- gcc/fortran/simplify.c.jj	2019-11-25 22:44:26.127328111 +0100
+++ gcc/fortran/simplify.c	2019-11-26 17:32:26.963525721 +0100
@@ -7656,7 +7656,7 @@ gfc_simplify_spread (gfc_expr *source, g
   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 "
--- gcc/testsuite/gfortran.dg/spread_size_limit_2.f90.jj	2019-11-26 17:47:25.578719250 +0100
+++ gcc/testsuite/gfortran.dg/spread_size_limit_2.f90	2019-11-26 17:40:48.881815325 +0100
@@ -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

	Jakub



More information about the Gcc-patches mailing list