Commit 4dc64371 by Thomas König

Fix PR fortran/93500, ICE on invalid.

Returning &gfc_bad_expr when simplifying bounds after a divisin by zero
happened results in the division by zero error actually reaching the user.

2020-04-19  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/93500
	* resolve.c (resolve_operator): If both operands are
	NULL, return false.
	* simplify.c (simplify_bound): If a division by zero
	was seen during bound simplification, free the
	corresponcing expression and return &gfc_bad_expr.

2020-04-19  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/93500
	* arith_divide_3.f90: New test.
parent e1113ffb
2020-04-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/93500
* resolve.c (resolve_operator): If both operands are
NULL, return false.
* simplify.c (simplify_bound): If a division by zero
was seen during bound simplification, free the
corresponcing expression and return &gfc_bad_expr.
2020-04-17 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/94090
......
......@@ -3992,6 +3992,9 @@ resolve_operator (gfc_expr *e)
op1 = e->value.op.op1;
op2 = e->value.op.op2;
if (op1 == NULL && op2 == NULL)
return false;
dual_locus_error = false;
/* op1 and op2 cannot both be BOZ. */
......
......@@ -4251,7 +4251,11 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
for (j = 0; j < d; j++)
gfc_free_expr (bounds[j]);
return bounds[d];
if (gfc_seen_div0)
return &gfc_bad_expr;
else
return bounds[d];
}
}
......
2020-04-19 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/93500
* arith_divide_3.f90: New test.
2020-04-19 Jakub Jelinek <jakub@redhat.com>
PR objc/94637
......
! { dg-do compile }
! { dg-options "-fcoarray=single" }
! PR 93500 - this used to cause an ICE
program p
integer :: a(min(2,0)/0) ! { dg-error "Division by zero" }
integer, save :: c[min(2,0)/0,*] ! { dg-error "Division by zero|must have constant shape" }
integer :: b = lbound(a) ! { dg-error "must be an array" }
print *,lcobound(c)
end program p
subroutine s
integer :: a(min(2,0)/0) ! { dg-error "Division by zero" }
integer, save :: c[min(2,0)/0,*] ! { dg-error "Division by zero" }
integer :: b = lbound(a)
print *,lcobound(c)
end subroutine s
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