From: Eric Botcazou Date: Tue, 19 Nov 2024 12:04:08 +0000 (+0100) Subject: ada: Fix pragma Compile_Time_Error for sizes of nonstatic array types X-Git-Tag: basepoints/gcc-16~3407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36023478657c64cb72bba3b4f9b7ed815997ae9f;p=thirdparty%2Fgcc.git 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 --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);