aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2015-11-07 20:18:17 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2015-11-07 20:18:17 +0000
commit57e596204fceef2e9196c76f0cb102e4fd66646d (patch)
treeba473afff940faab83ee3adf400dffb45cac490f /gcc/fortran
parent727cde644d6175dcc5e22d4e1214bf3bac621efc (diff)
downloadgcc-57e596204fceef2e9196c76f0cb102e4fd66646d.zip
gcc-57e596204fceef2e9196c76f0cb102e4fd66646d.tar.gz
gcc-57e596204fceef2e9196c76f0cb102e4fd66646d.tar.bz2
re PR fortran/68153 (ICE for intrinsic reshape with negative dim in effective shape)
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/68153 * check.c (gfc_check_reshape): Improve check for valid SHAPE argument. 2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/68153 * gfortran.dg/pr68153.f90: New test. From-SVN: r229939
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/check.c30
2 files changed, 35 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 15583d9..fc3afba 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,10 @@
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
+ PR fortran/68153
+ * check.c (gfc_check_reshape): Improve check for valid SHAPE argument.
+
+2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
+
PR fortran/68151
* match.c (match_case_selector): Check for invalid type.
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 6548a01..86dae5b 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -3711,6 +3711,36 @@ gfc_check_reshape (gfc_expr *source, gfc_expr *shape,
}
}
}
+ else if (shape->expr_type == EXPR_VARIABLE && shape->ref
+ && shape->ref->u.ar.type == AR_FULL && shape->ref->u.ar.dimen == 1
+ && shape->ref->u.ar.as
+ && shape->ref->u.ar.as->lower[0]->expr_type == EXPR_CONSTANT
+ && shape->ref->u.ar.as->lower[0]->ts.type == BT_INTEGER
+ && shape->ref->u.ar.as->upper[0]->expr_type == EXPR_CONSTANT
+ && shape->ref->u.ar.as->upper[0]->ts.type == BT_INTEGER
+ && shape->symtree->n.sym->attr.flavor == FL_PARAMETER)
+ {
+ int i, extent;
+ gfc_expr *e, *v;
+
+ v = shape->symtree->n.sym->value;
+
+ for (i = 0; i < shape_size; i++)
+ {
+ e = gfc_constructor_lookup_expr (v->value.constructor, i);
+ if (e == NULL)
+ break;
+
+ gfc_extract_int (e, &extent);
+
+ if (extent < 0)
+ {
+ gfc_error ("Element %d of actual argument of RESHAPE at %L "
+ "cannot be negative", i + 1, &shape->where);
+ return false;
+ }
+ }
+ }
if (pad != NULL)
{