https://gcc.gnu.org/g:24c5396f8cd6e93010612f09fb77845559e30692

commit r15-3112-g24c5396f8cd6e93010612f09fb77845559e30692
Author: Steve Baird <ba...@adacore.com>
Date:   Mon Aug 5 15:15:22 2024 -0700

    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.

Diff:
---
 gcc/ada/checks.adb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 3650c070b7a0..83879a519f7d 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
          =>

Reply via email to