[Ada] Fix problematic conversion of real literal in static context

Pierre-Marie de Rodat derodat@adacore.com
Wed Oct 20 19:27:55 GMT 2021


This gets rid of a bogus error issued for the conversion to a static
floating-point subtype of a named number which is not a machine number
of this floating-point subtype but happens to be very close (or equal)
to one of the nominal bounds of the subtype.

This conversion may not change the value of this named number in a
static context but needs to take into account the stored bounds of
the subtype, which are machine numbers, to raise Constraint_Error.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_eval.adb (Eval_Type_Conversion): If the target subtype is
	a static floating-point subtype and the result is a real literal,
	consider its machine-rounded value to raise Constraint_Error.
	(Test_In_Range): Turn local variables into constants.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2061 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211020/c5536c5c/attachment-0001.bin>


More information about the Gcc-patches mailing list