From: Eric Botcazou Date: Mon, 20 Apr 2020 21:31:42 +0000 (+0200) Subject: [Ada] Small adjustment to Get_Integer_Type function X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25a11453cae6975b7a10a7f30b2076e639713908;p=gcc.git [Ada] Small adjustment to Get_Integer_Type function 2020-06-18 Eric Botcazou gcc/ada/ * exp_attr.adb (Get_Integer_Type): Pick an unsigned type based on the Esize of the base type of the input type. --- diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 785ed25aed2..a96d2d5b732 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;