]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix pragma Compile_Time_Error for sizes of nonstatic array types
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 19 Nov 2024 12:04:08 +0000 (13:04 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:57:58 +0000 (10:57 +0100)
The pragma is consistenly rejected for the sizes of nonstatic array types
because Eval_Attribute does not evaluate it even if it is known.

gcc/ada/ChangeLog:

* sem_attr.adb (Eval_Attribute): Treat the various size attributes
like Component_Size for nonstatic array types.

gcc/ada/sem_attr.adb

index 4e06ec54978fbbcd7018d7aa97c8f85c7c13dd72..2315d515ac4d9c61bf02c51826e7c08c2c8b4cef 100644 (file)
@@ -8824,6 +8824,8 @@ package body Sem_Attr is
       --  unconstrained arrays. Furthermore, it is essential to fold this
       --  in the packed case, since otherwise the value will be incorrect.
       --  Moreover, the exact same reasoning can be applied to Alignment.
+      --  Likewise for the various size attributes, although folding will
+      --  never succeed for them with unconstrained arrays.
 
       elsif Id = Attribute_Atomic_Always_Lock_Free      or else
             Id = Attribute_Definite                     or else
@@ -8835,7 +8837,12 @@ package body Sem_Attr is
             Id = Attribute_Type_Class                   or else
             Id = Attribute_Unconstrained_Array          or else
             Id = Attribute_Component_Size               or else
-            Id = Attribute_Alignment
+            Id = Attribute_Alignment                    or else
+            Id = Attribute_Machine_Size                 or else
+            Id = Attribute_Object_Size                  or else
+            Id = Attribute_Size                         or else
+            Id = Attribute_VADS_Size                    or else
+            Id = Attribute_Value_Size
       then
          Static := False;
          Set_Is_Static_Expression (N, False);