From b7b848f5d7984a9984e0a518b75ff91a0de0cb32 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 27 Nov 2019 11:00:50 +0100 Subject: [PATCH] re PR fortran/91944 (ICE in gfc_conv_array_initializer, at fortran/trans-array.c:6156) 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 | 6 ++++++ gcc/fortran/simplify.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gfortran.dg/spread_size_limit_2.f90 | 11 +++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/spread_size_limit_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 25252501b19..4cf6e9e3d1a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-11-27 Jakub Jelinek + + 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 PR middle-end/92463 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index b02c549ecff..93f3da38af6 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -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 " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab455910c4d..92d6855694b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-11-27 Jakub Jelinek + 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 index 00000000000..3ea064e267f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/spread_size_limit_2.f90 @@ -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 -- 2.30.2