Commit 57e59620 by Steven G. Kargl

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
parent 727cde64
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.
......
......@@ -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)
{
......
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68153
* gfortran.dg/pr68153.f90: New test.
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68151
* gfortran.dg/pr68151.f90: New test.
......
! { dg-do compile }
! PR fortran/68153
! Original code contribute by Gerhard Steinmetz
! <gerhard dot steinmetz dot fortran at t-online dot de>
!
program foo
integer, parameter :: a(2) = [2, -2]
integer, parameter :: b(2,2) = reshape([1, 2, 3, 4], a) ! { dg-error "cannot be negative" }
end program foo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment