diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-04-20 23:31:42 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-18 05:08:17 -0400 |
commit | 25a11453cae6975b7a10a7f30b2076e639713908 (patch) | |
tree | 6106387dc3aeb11ed33c17ecf4ef98e4ee0ca58a /gcc/ada | |
parent | 2e64cf055250718d8e1659d37738c9eb2d2da1e3 (diff) | |
download | gcc-25a11453cae6975b7a10a7f30b2076e639713908.zip gcc-25a11453cae6975b7a10a7f30b2076e639713908.tar.gz gcc-25a11453cae6975b7a10a7f30b2076e639713908.tar.bz2 |
[Ada] Small adjustment to Get_Integer_Type function
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.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/exp_attr.adb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 785ed25..a96d2d5 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -1750,23 +1750,25 @@ package body Exp_Attr is ---------------------- function Get_Integer_Type (Typ : Entity_Id) return Entity_Id is - Siz : constant Uint := RM_Size (Base_Type (Typ)); + Siz : constant Uint := Esize (Base_Type (Typ)); Int_Typ : Entity_Id; begin - -- We need to accommodate unsigned values + -- We need to accommodate invalid values of the base type since we + -- accept them for Enum_Rep and Pos, so we reason on the Esize. And + -- we use an unsigned type since the enumeration type is unsigned. - if Siz < RM_Size (Standard_Short_Short_Integer) then - Int_Typ := Standard_Short_Short_Integer; + if Siz <= Esize (Standard_Short_Short_Unsigned) then + Int_Typ := Standard_Short_Short_Unsigned; - elsif Siz < RM_Size (Standard_Short_Integer) then - Int_Typ := Standard_Short_Integer; + elsif Siz <= Esize (Standard_Short_Unsigned) then + Int_Typ := Standard_Short_Unsigned; - elsif Siz < RM_Size (Standard_Integer) then - Int_Typ := Standard_Integer; + elsif Siz <= Esize (Standard_Unsigned) then + Int_Typ := Standard_Unsigned; else - Int_Typ := Standard_Long_Long_Integer; + raise Program_Error; end if; return Int_Typ; |