]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix aspect Linker_Section ignored on subprogram body
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 8 May 2023 14:17:33 +0000 (16:17 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:28 +0000 (10:16 +0200)
The compiler is waiting for the freeze node of the body, but it is never
generated since the freezing of the body is not delayed.  The change also
removes an obsolete piece of code.

gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Specifications): Add missing items
in the list of aspects handled by means of Insert_Pragma.
<Aspect_Linker_Section>: Remove obsolete code.  Do not delay the
processing of the aspect if the entity is already frozen.

gcc/ada/sem_ch13.adb

index 3a99c5df3a56694e23ef608c3857f969a02dd2f3..cead44c52a1c4f4436e13aaf83f2e0e5d42dd6f4 100644 (file)
@@ -1408,19 +1408,33 @@ package body Sem_Ch13 is
       --  Subsidiary to the analysis of aspects
       --    Abstract_State
       --    Attach_Handler
+      --    Async_Readers
+      --    Async_Writers
+      --    Constant_After_Elaboration
       --    Contract_Cases
+      --    Convention
+      --    Default_Initial_Condition
+      --    Default_Storage_Pool
       --    Depends
       --    Ghost
       --    Global
       --    Initial_Condition
       --    Initializes
+      --    Max_Entry_Queue_Depth
+      --    Max_Entry_Queue_Length
+      --    Max_Queue_Length
+      --    No_Caching
+      --    Part_Of
       --    Post
       --    Pre
       --    Refined_Depends
       --    Refined_Global
+      --    Refined_Post
       --    Refined_State
       --    SPARK_Mode
+      --    Secondary_Stack_Size
       --    Subprogram_Variant
+      --    Volatile_Function
       --    Warnings
       --  Insert pragma Prag such that it mimics the placement of a source
       --  pragma of the same kind. Flag Is_Generic should be set when the
@@ -3061,16 +3075,11 @@ package body Sem_Ch13 is
                          Expression => Relocate_Node (Expr))),
                      Pragma_Name                  => Name_Linker_Section);
 
-                  --  Linker_Section does not need delaying, as its argument
-                  --  must be a static string. Furthermore, if applied to
-                  --  an object with an explicit initialization, the object
-                  --  must be frozen in order to elaborate the initialization
-                  --  code. (This is already done for types with implicit
-                  --  initialization, such as protected types.)
+                  --  No need to delay the processing if the entity is already
+                  --  frozen. This should only happen for subprogram bodies.
 
-                  if Nkind (N) = N_Object_Declaration
-                    and then Has_Init_Expression (N)
-                  then
+                  if Is_Frozen (E) then
+                     pragma Assert (Nkind (N) = N_Subprogram_Body);
                      Delay_Required := False;
                   end if;
 
@@ -4724,9 +4733,7 @@ package body Sem_Ch13 is
             --  For an aspect that applies to a type, indicate whether it
             --  appears on a partial view of the type.
 
-            if Is_Type (E)
-              and then Is_Private_Type (E)
-            then
+            if Is_Type (E) and then Is_Private_Type (E) then
                Set_Aspect_On_Partial_View (Aspect);
             end if;