public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1633] [Ada] Avoid passing Enum_Lit'Size to the back end
@ 2021-06-18 8:39 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-18 8:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7
commit r12-1633-ga34ce7c5dff5281eb06e82d0b2fb8e3fe6a36ac7
Author: Bob Duff <duff@adacore.com>
Date: Mon Mar 22 07:39:40 2021 -0400
[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.
Diff:
---
gcc/ada/sem_attr.adb | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index f9b17c75d4b..46c3d65efa3 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-18 8:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 8:39 [gcc r12-1633] [Ada] Avoid passing Enum_Lit'Size to the back end Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).