mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-13 13:21:12 +08:00
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.
This commit is contained in:
parent
e1113ffbd6
commit
4dc6437183
gcc
@ -1,3 +1,12 @@
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
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
|
||||
|
17
gcc/testsuite/gfortran.dg/arith_divide_3.f90
Normal file
17
gcc/testsuite/gfortran.dg/arith_divide_3.f90
Normal file
@ -0,0 +1,17 @@
|
||||
! { 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
|
Loading…
x
Reference in New Issue
Block a user