From: Steven G. Kargl Date: Tue, 22 Oct 2019 18:18:59 +0000 (+0000) Subject: re PR fortran/92174 (runtime error: index 15 out of bounds for type 'gfc_expr *[15]) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ebb3afe2b98a9a4b1c8cc5fd2745a1037c06d827;p=gcc.git re PR fortran/92174 (runtime error: index 15 out of bounds for type 'gfc_expr *[15]) 2019-10-22 Steven G. Kargl PR fortran/92174 * decl.c (attr_decl1): Move check for F2018:C822 from here ... * array.c (gfc_set_array_spec): ... to here. From-SVN: r277297 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5ba62d251ef..841aa66f378 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-22 Steven G. Kargl + + PR fortran/92174 + * decl.c (attr_decl1): Move check for F2018:C822 from here ... + * array.c (gfc_set_array_spec): ... to here. + 2019-10-18 Steven G. Kargl PR fortran/69455 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 427110bee74..f0980dd9cef 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -862,6 +862,10 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) sym->as->cotype = as->cotype; sym->as->corank = as->corank; + /* Check F2018:C822. */ + if (sym->as->rank + sym->as->corank > GFC_MAX_DIMENSIONS) + goto too_many; + for (i = 0; i < as->corank; i++) { sym->as->lower[sym->as->rank + i] = as->lower[i]; @@ -880,6 +884,10 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) sym->as->cray_pointee = as->cray_pointee; sym->as->cp_was_assumed = as->cp_was_assumed; + /* Check F2018:C822. */ + if (sym->as->rank + sym->as->corank > GFC_MAX_DIMENSIONS) + goto too_many; + for (i = 0; i < sym->as->corank; i++) { sym->as->lower[as->rank + i] = sym->as->lower[i]; @@ -894,6 +902,12 @@ gfc_set_array_spec (gfc_symbol *sym, gfc_array_spec *as, locus *error_loc) free (as); return true; + +too_many: + + gfc_error ("rank + corank of %qs exceeds %d at %C", sym->name, + GFC_MAX_DIMENSIONS); + return false; } diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 59e0eac1f32..25a3967fac8 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -8524,15 +8524,6 @@ attr_decl1 (void) goto cleanup; } - /* Check F2018:C822. */ - if (sym->attr.dimension && sym->attr.codimension - && sym->as && sym->as->rank + sym->as->corank > 15) - { - gfc_error ("rank + corank of %qs exceeds 15 at %C", sym->name); - m = MATCH_ERROR; - return m; - } - if (sym->attr.cray_pointee && sym->as != NULL) { /* Fix the array spec. */