Commit a7191e01 by Eric Botcazou Committed by Pierre-Marie de Rodat

[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  <ebotcazou@adacore.com>

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
parent f9534f4b
2019-07-23 Eric Botcazou <ebotcazou@adacore.com> 2019-07-23 Eric Botcazou <ebotcazou@adacore.com>
* 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 <ebotcazou@adacore.com>
* repinfo.adb (List_Component_Layout): Pass Decimal to UI_Write. * repinfo.adb (List_Component_Layout): Pass Decimal to UI_Write.
(Write_Val): Likewise. (Write_Val): Likewise.
......
...@@ -435,7 +435,7 @@ package body Checks is ...@@ -435,7 +435,7 @@ package body Checks is
-- Fall through for cases where we do set the flag -- 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); Possible_Local_Raise (N, Standard_Constraint_Error);
end Activate_Overflow_Check; end Activate_Overflow_Check;
......
...@@ -11000,6 +11000,11 @@ package body Exp_Ch4 is ...@@ -11000,6 +11000,11 @@ package body Exp_Ch4 is
Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr)); Rewrite (Expr, Unchecked_Convert_To (Ityp, Expr));
end if; 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); Generate_Range_Check (Expr, Target_Type, CE_Range_Check_Failed);
end Discrete_Range_Check; end Discrete_Range_Check;
...@@ -12096,11 +12101,6 @@ package body Exp_Ch4 is ...@@ -12096,11 +12101,6 @@ package body Exp_Ch4 is
or else (Is_Fixed_Point_Type (Etype (Expression (N))) or else (Is_Fixed_Point_Type (Etype (Expression (N)))
and then Conversion_OK (N))) and then Conversion_OK (N)))
then 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, -- If Address is either a source type or target type,
-- suppress range check to avoid typing anomalies when -- suppress range check to avoid typing anomalies when
-- it is a visible integer type. -- it is a visible integer type.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment