From a7191e01187b6ff6429699f09fed8f3fbb018b74 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 23 Jul 2019 08:13:26 +0000 Subject: [PATCH] [Ada] Eliminate redundant overflow checks for conversions from fixed-point This eliminates redundant overflow checks that are generated for conversions from fixed-point to integer types when range checks are also enabled (which is the default), as the former checks are subsumed into the latter checks. No functional changes. 2019-07-23 Eric Botcazou gcc/ada/ * checks.adb (Activate_Overflow_Check): Remove redundant argument. * exp_ch4.adb (Discrete_Range_Check): Reset the overflow flag. (Expand_N_Type_Conversion): Do not reset it here. From-SVN: r273724 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/checks.adb | 2 +- gcc/ada/exp_ch4.adb | 10 +++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 445e70e8a46..786949565d0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-07-23 Eric Botcazou + + * checks.adb (Activate_Overflow_Check): Remove redundant + argument. + * exp_ch4.adb (Discrete_Range_Check): Reset the overflow flag. + (Expand_N_Type_Conversion): Do not reset it here. + 2019-07-23 Eric Botcazou * repinfo.adb (List_Component_Layout): Pass Decimal to UI_Write. diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index e1f7f9a5085..2eff274e7d0 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -435,7 +435,7 @@ package body Checks is -- Fall through for cases where we do set the flag - Set_Do_Overflow_Check (N, True); + Set_Do_Overflow_Check (N); Possible_Local_Raise (N, Standard_Constraint_Error); end Activate_Overflow_Check; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index dc2146c50e5..2af54a7d50b 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -11000,6 +11000,11 @@ package body Exp_Ch4 is Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr)); end if; + -- Reset overflow flag, since the range check will include + -- dealing with possible overflow, and generate the check. + + Set_Do_Overflow_Check (N, False); + Generate_Range_Check (Expr, Target_Type, CE_Range_Check_Failed); end Discrete_Range_Check; @@ -12096,11 +12101,6 @@ package body Exp_Ch4 is or else (Is_Fixed_Point_Type (Etype (Expression (N))) and then Conversion_OK (N))) then - -- Reset overflow flag, since the range check will include - -- dealing with possible overflow, and generate the check. - - Set_Do_Overflow_Check (N, False); - -- If Address is either a source type or target type, -- suppress range check to avoid typing anomalies when -- it is a visible integer type. -- 2.30.2