[Ada] Plug small loophole in Generate_Range_Check
The Generate_Range_Check routine is responsible for generating range
checks in the scalar case. It automatically deals with possible
overflow in the process when the source and the target base types are
different.
However there is one case where overflow is not dealt with correctly,
namely when the target base type is narrower than the source base type
and both are floating-point types. In this case, the routine will
convert the source type to the target base type without checking for
overflow. In practice this does not matter much because the conversion
would yield an infinity on overflow, which would then fail the
subsequent range check. However it's more correct to have a proper
overflow check with -gnateF than relying on the infinity.
2019-07-23 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* checks.adb (Convert_And_Check_Range): Add Suppress parameter
and pass it in the call to Insert_Actions. Rename local
variable.
(Generate_Range_Check): Minor comment fixes. Pass Range_Check
in the first call to Convert_And_Check_Range and All_Checks in
the second call.
* exp_ch4.adb (Expand_N_Type_Conversion): Reset the
Do_Overflow_Check flag in the float-to-float case too if there
is also a range check.
gcc/testsuite/
* gnat.dg/range_check5.adb: New testcase.
From-SVN: r273725