]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Eliminated-mode overflow check not eliminated
authorSteve Baird <baird@adacore.com>
Mon, 5 Aug 2024 22:15:22 +0000 (15:15 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 23 Aug 2024 08:51:04 +0000 (10:51 +0200)
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.

gcc/ada/checks.adb

index 3650c070b7a097e422c49c6e1892a91a6b5673e3..83879a519f7df3ad8aedfa354b74d0521ceeeb78 100644 (file)
@@ -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
          =>