aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2021-03-22 07:39:40 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-18 04:36:53 -0400
commita34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7 (patch)
tree653f46ea7ee12f7522c89ba2ee4c9f5f2239b01b /gcc
parent548280b996ea7e6283193d6c8a3c03d44ef36681 (diff)
downloadgcc-a34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7.zip
gcc-a34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7.tar.gz
gcc-a34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7.tar.bz2
[Ada] Avoid passing Enum_Lit'Size to the back end
gcc/ada/ * sem_attr.adb (Eval_Attribute): For Enum_Lit'Size, use Enum_Type'Object_Size.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_attr.adb21
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index f9b17c7..46c3d65 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -7983,14 +7983,27 @@ package body Sem_Attr is
end if;
end;
- -- For Size, give size of object if available, otherwise we
- -- cannot fold Size.
-
elsif Id = Attribute_Size then
+ -- For Enum_Lit'Size, use Enum_Type'Object_Size. Taking the 'Size
+ -- of a literal is kind of a strange thing to do, so we don't want
+ -- to pass this oddity on to the back end. Note that Etype of an
+ -- enumeration literal is always a (base) type, never a
+ -- constrained subtype, so the Esize is always known.
+
if Is_Entity_Name (P)
- and then Known_Static_Esize (Entity (P))
+ and then Ekind (Entity (P)) = E_Enumeration_Literal
+ then
+ pragma Assert (Known_Static_Esize (Etype (P)));
+ Compile_Time_Known_Attribute (N, Esize (Etype (P)));
+
+ -- Otherwise, if Size is available, use that
+
+ elsif Is_Entity_Name (P) and then Known_Static_Esize (Entity (P))
then
Compile_Time_Known_Attribute (N, Esize (Entity (P)));
+
+ -- Otherwise, we cannot fold
+
else
Check_Expressions;
end if;