+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.
+
2015-11-17 Steven G. Kargl <kargl@gcc.gnu.org>
* primary.c (gfc_match_structure_constructor): Fix whitespace.
gfc_expr *
gfc_simplify_spread (gfc_expr *source, gfc_expr *dim_expr, gfc_expr *ncopies_expr)
{
- gfc_expr *result = 0L;
- int i, j, dim, ncopies;
+ gfc_expr *result = NULL;
+ int nelem, i, j, dim, ncopies;
mpz_t size;
if ((!gfc_is_constant_expr (source)
else
mpz_init_set_ui (size, 1);
- if (mpz_get_si (size)*ncopies > flag_max_array_constructor)
- return NULL;
+ nelem = mpz_get_si (size) * ncopies;
+ if (nelem > flag_max_array_constructor)
+ {
+ if (gfc_current_ns->sym_root->n.sym->attr.flavor == FL_PARAMETER)
+ {
+ gfc_error ("The number of elements (%d) in the array constructor "
+ "at %L requires an increase of the allowed %d upper "
+ "limit. See %<-fmax-array-constructor%> option.",
+ nelem, &source->where, flag_max_array_constructor);
+ return &gfc_bad_expr;
+ }
+ else
+ return NULL;
+ }
if (source->expr_type == EXPR_CONSTANT)
{
--- /dev/null
+! { dg-do compile }
+! PR fortran/43996
+!
+real, parameter :: a(720,360) = spread((/(j, j=1,720) /), dim=2, ncopies=360) ! { dg-error "number of elements" }
+real x
+x = a(720,360)
+end