diff options
author | Steve Baird <baird@adacore.com> | 2024-08-05 15:15:22 -0700 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-23 10:51:04 +0200 |
commit | 24c5396f8cd6e93010612f09fb77845559e30692 (patch) | |
tree | 4b6de9f48547b90cdf18def1793e30a140732700 | |
parent | 40903c7decc4632ce54617ea9d68ead3b126a52e (diff) | |
download | gcc-24c5396f8cd6e93010612f09fb77845559e30692.zip gcc-24c5396f8cd6e93010612f09fb77845559e30692.tar.gz gcc-24c5396f8cd6e93010612f09fb77845559e30692.tar.bz2 |
ada: Eliminated-mode overflow check not eliminated
If the Overflow_Mode in effect is Eliminated, then evaluating an arithmetic
op such as addition or subtraction should not fail an overflow check.
Fix a bug which resulted in such an overflow check failure.
gcc/ada/
* checks.adb (Is_Signed_Integer_Arithmetic_Op): Return True in the
case of relational operator whose operands are of a signed integer
type.
-rw-r--r-- | gcc/ada/checks.adb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 3650c07..83879a51 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -330,10 +330,11 @@ package body Checks is function Is_Signed_Integer_Arithmetic_Op (N : Node_Id) return Boolean; -- Returns True if node N is for an arithmetic operation with signed - -- integer operands. This includes unary and binary operators, and also - -- if and case expression nodes where the dependent expressions are of - -- a signed integer type. These are the kinds of nodes for which special - -- handling applies in MINIMIZED or ELIMINATED overflow checking mode. + -- integer operands. This includes unary and binary operators (including + -- comparison operators), and also if and case expression nodes which + -- yield a value of a signed integer type. + -- These are the kinds of nodes for which special handling applies in + -- MINIMIZED or ELIMINATED overflow checking mode. function Range_Or_Validity_Checks_Suppressed (Expr : Node_Id) return Boolean; @@ -8337,6 +8338,9 @@ package body Checks is => return Is_Signed_Integer_Type (Etype (N)); + when N_Op_Compare => + return Is_Signed_Integer_Type (Etype (Left_Opnd (N))); + when N_Case_Expression | N_If_Expression => |