diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-11-02 22:54:01 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-11-27 04:15:47 -0500 |
commit | 84c54629c2fb6dae0e7d97a2c57e894899f2b944 (patch) | |
tree | dde824100727d455c32afe4c3f0770b46f2b02ab /gcc/ada/checks.ads | |
parent | 2d1504186ee9d83fbc93f4b6880d55dcdd8daaff (diff) | |
download | gcc-84c54629c2fb6dae0e7d97a2c57e894899f2b944.zip gcc-84c54629c2fb6dae0e7d97a2c57e894899f2b944.tar.gz gcc-84c54629c2fb6dae0e7d97a2c57e894899f2b944.tar.bz2 |
[Ada] Optimize generation of checks for fixed-point types
gcc/ada/
* checks.ads (Determine_Range_To_Discrete): New procedure.
* checks.adb (Apply_Scalar_Range_Check): Call it to determine
a range for the expression when the target type is discrete.
And also apply the tests for discrete types to fixed-point
types when they are treated as integers.
(Apply_Type_Conversion_Checks): Apply checks to conversions
involving fixed-point types when they are treated as integers.
(Determine_Range) <N_Type_Conversion>: Factor out code into...
(Determine_Range_To_Discrete): ...this new procedure and add
support for fixed-point types when they are treated as integers.
* einfo.ads (Type_High_Bound): Remove obsolete sentence.
(Type_Low_Bound): Likewise.
* exp_ch4.adb (Discrete_Range_Check): Remove obsolete code.
(Real_Range_Check): Likewise.
(Expand_N_Type_Conversion): In case of a no-op conversion, clear
the Do_Range_Check flag on the operand before substituting it.
Remove calls to Real_Range_Check and Discrete_Range_Check that
are not guarded by the Do_Range_Check flag, and an assertion.
* sem_res.adb (Resolve_Type_Conversion): Always apply range
checks in GNATprove mode; in normal mode, use the updated type
of the operand in the test against Universal_Fixed. Remove
obsolete code setting the Do_Range_Check flag at the end.
Diffstat (limited to 'gcc/ada/checks.ads')
-rw-r--r-- | gcc/ada/checks.ads | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads index aca1b7e..d75c602 100644 --- a/gcc/ada/checks.ads +++ b/gcc/ada/checks.ads @@ -338,6 +338,21 @@ package Checks is -- For that to happen, the possibility of arguments of infinite or NaN -- value should be taken into account, which is not the case currently. + procedure Determine_Range_To_Discrete + (N : Node_Id; + OK : out Boolean; + Lo : out Uint; + Hi : out Uint; + Fixed_Int : Boolean := False; + Assume_Valid : Boolean := False); + -- Similar to Determine_Range, but attempts to return a discrete range even + -- if N is not of a discrete type by doing a conversion. The Fixed_Int flag + -- if set causes any fixed-point values to be treated as though they were + -- discrete values (i.e. the underlying integer value is used), in which + -- case no conversion is needed. At the current time, this is used only for + -- discrete types, for fixed-point types if Fixed_Int is set, and also for + -- floating-point types in GNATprove, see Determine_Range_R above. + procedure Install_Null_Excluding_Check (N : Node_Id); -- Determines whether an access node requires a run-time access check and -- if so inserts the appropriate run-time check. |