diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-04-14 11:20:18 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-17 04:14:10 -0400 |
commit | 4ea4df3af88f33686813b7db70fbe3e37b7dfecc (patch) | |
tree | 2ae2de613708ba0668fbe8bc618fe7014934098e /gcc | |
parent | c3a2dc654c8e9474dbf0de2da168cd7816eae813 (diff) | |
download | gcc-4ea4df3af88f33686813b7db70fbe3e37b7dfecc.zip gcc-4ea4df3af88f33686813b7db70fbe3e37b7dfecc.tar.gz gcc-4ea4df3af88f33686813b7db70fbe3e37b7dfecc.tar.bz2 |
[Ada] Couple of small tweaks related to integer conversions
2020-06-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_attr.adb (Get_Integer_Type): Use standard types without
a specific size.
* sem_res.adb (Resolve_Unchecked_Type_Conversion): Remove a
redundant intermediate conversion to Universal_Integer.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_attr.adb | 14 | ||||
-rw-r--r-- | gcc/ada/sem_res.adb | 12 |
2 files changed, 19 insertions, 7 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index ea36be0..888b112 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -1756,17 +1756,17 @@ package body Exp_Attr is begin -- We need to accommodate unsigned values - if Siz < 8 then - Int_Typ := Standard_Integer_8; + if Siz < RM_Size (Standard_Short_Short_Integer) then + Int_Typ := Standard_Short_Short_Integer; - elsif Siz < 16 then - Int_Typ := Standard_Integer_16; + elsif Siz < RM_Size (Standard_Short_Integer) then + Int_Typ := Standard_Short_Integer; - elsif Siz < 32 then - Int_Typ := Standard_Integer_32; + elsif Siz < RM_Size (Standard_Integer) then + Int_Typ := Standard_Integer; else - Int_Typ := Standard_Integer_64; + Int_Typ := Standard_Long_Long_Integer; end if; return Int_Typ; diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 4267626..7e65350 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -11998,6 +11998,18 @@ package body Sem_Res is Resolve (Operand, Opnd_Type); + -- If the expression is a conversion to universal integer of an + -- an expression with an integer type, then we can eliminate the + -- intermediate conversion to universal integer. + + if Nkind (Operand) = N_Type_Conversion + and then Entity (Subtype_Mark (Operand)) = Universal_Integer + and then Is_Integer_Type (Etype (Expression (Operand))) + then + Rewrite (Operand, Relocate_Node (Expression (Operand))); + Analyze_And_Resolve (Operand); + end if; + -- In an inlined context, the unchecked conversion may be applied -- to a literal, in which case its type is the type of the context. -- (In other contexts conversions cannot apply to literals). |