aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2018-02-25 16:50:50 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2018-02-25 16:50:50 +0000
commit09ef33c10863f37a99396040bfa4329de1271eb3 (patch)
treebc03b941fba4b3175b46ed2c886baf947469fd67 /gcc/fortran
parent8fba26f48f4224ca9f2faab0b2a28e20784a119c (diff)
downloadgcc-09ef33c10863f37a99396040bfa4329de1271eb3.zip
gcc-09ef33c10863f37a99396040bfa4329de1271eb3.tar.gz
gcc-09ef33c10863f37a99396040bfa4329de1271eb3.tar.bz2
re PR fortran/83633 (gfortran internal compiler error for explicit-shape array with non-constant bounds)
2018-02-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83633 * decl.c (variable_decl): Check that an explicit-shape-array with nonconstant bounds is allowed. 2018-02-25 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83633 * gfortran.dg/explicit_shape_1.f90: New test. * gfortran.dg/automatic_module_variable.f90: Update regex. * gfortran.dg/bad_automatic_objects_1.f90: Ditto. * gfortran.dg/constant_shape.f90: Ditto. * gfortran.dg/dec_structure_23.f90: Ditto. * gfortran.dg/pr78240.f90: Ditto. From-SVN: r257971
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/decl.c49
2 files changed, 54 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2c2aa2b..76ac274 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-25 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/83633
+ * decl.c (variable_decl): Check that an explicit-shape-array with
+ nonconstant bounds is allowed.
+
2018-02-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/84523
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index e377a21..dcfda27 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2304,7 +2304,10 @@ variable_decl (int elem)
/* At this point, we know for sure if the symbol is PARAMETER and can thus
determine (and check) whether it can be implied-shape. If it
was parsed as assumed-size, change it because PARAMETERs can not
- be assumed-size. */
+ be assumed-size.
+
+ An explicit-shape-array cannot appear under several conditions.
+ That check is done here as well. */
if (as)
{
if (as->type == AS_IMPLIED_SHAPE && current_attr.flavor != FL_PARAMETER)
@@ -2326,6 +2329,50 @@ variable_decl (int elem)
m = MATCH_ERROR;
goto cleanup;
}
+
+ /* F2018:C830 (R816) An explicit-shape-spec whose bounds are not
+ constant expressions shall appear only in a subprogram, derived
+ type definition, BLOCK construct, or interface body. */
+ if (as->type == AS_EXPLICIT
+ && gfc_current_state () != COMP_BLOCK
+ && gfc_current_state () != COMP_DERIVED
+ && gfc_current_state () != COMP_FUNCTION
+ && gfc_current_state () != COMP_INTERFACE
+ && gfc_current_state () != COMP_SUBROUTINE)
+ {
+ gfc_expr *e;
+ bool not_constant = false;
+
+ for (int i = 0; i < as->rank; i++)
+ {
+ e = gfc_copy_expr (as->lower[i]);
+ gfc_resolve_expr (e);
+ gfc_simplify_expr (e, 0);
+ if (e && (e->expr_type != EXPR_CONSTANT))
+ {
+ not_constant = true;
+ break;
+ }
+ gfc_free_expr (e);
+
+ e = gfc_copy_expr (as->upper[i]);
+ gfc_resolve_expr (e);
+ gfc_simplify_expr (e, 0);
+ if (e && (e->expr_type != EXPR_CONSTANT))
+ {
+ not_constant = true;
+ break;
+ }
+ gfc_free_expr (e);
+ }
+
+ if (not_constant)
+ {
+ gfc_error ("Explicit shaped array with nonconstant bounds at %C");
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+ }
}
char_len = NULL;