public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-400] ada: Fix pragma Compile_Time_Error for alignment of array types
@ 2024-05-13  8:35 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2024-05-13  8:35 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2fc8ea4af4ad63a9675aef812f746fa91ecfabc8

commit r15-400-g2fc8ea4af4ad63a9675aef812f746fa91ecfabc8
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Jan 19 11:46:16 2024 +0100

    ada: Fix pragma Compile_Time_Error for alignment of array types
    
    The pragma is consistenly rejected for the alignment of array types because
    Eval_Attribute does not evaluate it even if it is known.
    
    gcc/ada/
    
            * sem_attr.adb (Eval_Attribute): Treat Alignment like Component_Size
            for array types.

Diff:
---
 gcc/ada/sem_attr.adb | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index e80a144ebb24..65442d45a85f 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -8729,14 +8729,15 @@ package body Sem_Attr is
       --  Unconstrained_Array are again exceptions, because they apply as well
       --  to unconstrained types.
 
+      --  Folding can also be done for Preelaborable_Initialization based on
+      --  whether the prefix type has preelaborable initialization, even though
+      --  the attribute is nonstatic.
+
       --  In addition Component_Size is an exception since it is possibly
       --  foldable, even though it is never static, and it does apply to
       --  unconstrained arrays. Furthermore, it is essential to fold this
       --  in the packed case, since otherwise the value will be incorrect.
-
-      --  Folding can also be done for Preelaborable_Initialization based on
-      --  whether the prefix type has preelaborable initialization, even though
-      --  the attribute is nonstatic.
+      --  Moreover, the exact same reasoning can be applied to Alignment.
 
       elsif Id = Attribute_Atomic_Always_Lock_Free      or else
             Id = Attribute_Definite                     or else
@@ -8747,7 +8748,8 @@ package body Sem_Attr is
             Id = Attribute_Preelaborable_Initialization or else
             Id = Attribute_Type_Class                   or else
             Id = Attribute_Unconstrained_Array          or else
-            Id = Attribute_Component_Size
+            Id = Attribute_Component_Size               or else
+            Id = Attribute_Alignment
       then
          Static := False;
          Set_Is_Static_Expression (N, False);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-13  8:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13  8:35 [gcc r15-400] ada: Fix pragma Compile_Time_Error for alignment of array types Marc Poulhi?s

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).