https://gcc.gnu.org/g:36023478657c64cb72bba3b4f9b7ed815997ae9f

commit r15-6146-g36023478657c64cb72bba3b4f9b7ed815997ae9f
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Tue Nov 19 13:04:08 2024 +0100

    ada: Fix pragma Compile_Time_Error for sizes of nonstatic array types
    
    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.

Diff:
---
 gcc/ada/sem_attr.adb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 4e06ec54978f..2315d515ac4d 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -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);

Reply via email to