[Ada] Small adjustment to Get_Integer_Type function

Pierre-Marie de Rodat derodat@adacore.com
Thu Jun 18 09:13:20 GMT 2020


The Get_Integer_Type function is used by the expander when generating
code for the Enum_Rep and Pos attributes applied to an enumeration type.
The expansion generates a direct conversion from the enumeration type
to the result type, which is nominally Universal_Integer; therefore,
in order to preserve the size information, an intermediate conversion
to a smaller integer type is introduced by means of Get_Integer_Type.

The type is picked based on the RM_Size of the base type, which means
that it may not be large enough to handle invalid values of this base
type, which might seem desirable for the Enum_Rep and Pos attributes.

So this changes the function to use the Esize of the base type instead,
and also to return an unsigned type, which is more consistent with the
enumeration type source.  There is also a small tweak for CCG.

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

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_attr.adb (Get_Integer_Type): Pick an unsigned type based
	on the Esize of the base type of the input type.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 1463 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200618/f81d22de/attachment-0001.bin>


More information about the Gcc-patches mailing list