From: Steve Baird <ba...@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 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 3650c070b7a..83879a519f7 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
          =>
-- 
2.45.2

Reply via email to