]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Make Exp_Ch9.Build_Task_Allocate_Block a function
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 22 Nov 2025 14:19:28 +0000 (15:19 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 9 Jan 2026 10:57:12 +0000 (11:57 +0100)
This streamlines the code in the callers.  No functional changes.

gcc/ada/ChangeLog:

* exp_ch9.ads (Build_Task_Allocate_Block): Change to function and
remove first formal parameter.
* exp_ch9.adb (Build_Task_Allocate_Block): Likewise.  Return an
anonymous list of nodes.
* exp_aggr.adb (Convert_Aggr_In_Allocator): Adjust to above change.
* exp_ch4.adb (Expand_N_Allocator): Likewise.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.

gcc/ada/exp_aggr.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_ch9.ads

index 0a0c857b45eea6f4a662b17f1016dff5d465889e..24fd5b5f92aa5249aee0837e8170a1e10e67289b 100644 (file)
@@ -3715,20 +3715,13 @@ package body Exp_Aggr is
    begin
       if Has_Default_Init_Comps (Aggr) then
          declare
-            Init_Stmts : constant List_Id := Late_Expansion (Aggr, Typ, Occ);
+            Stmts : constant List_Id := Late_Expansion (Aggr, Typ, Occ);
 
          begin
             if Has_Task (Typ) then
-               declare
-                  Actions : constant List_Id := New_List;
-
-               begin
-                  Build_Task_Allocate_Block (Actions, Aggr, Init_Stmts);
-                  Insert_Actions (N, Actions);
-               end;
-
+               Insert_Actions (N, Build_Task_Allocate_Block (Aggr, Stmts));
             else
-               Insert_Actions (N, Init_Stmts);
+               Insert_Actions (N, Stmts);
             end if;
          end;
 
index 1c9dc07b4ff3a2625b6e788a5e2a7e2381d5ab1b..1d167e01b8c39816a243fe3d9773dc0dc85f7eec 100644 (file)
@@ -5023,15 +5023,9 @@ package body Exp_Ch4 is
                --  create a specific block to activate the created tasks.
 
                if Has_Task (Etyp) then
-                  declare
-                     Actions : constant List_Id := New_List;
-
-                  begin
-                     Build_Task_Allocate_Block
-                       (Actions, Relocate_Node (N), Init_Stmts);
-                     Insert_Actions (N, Actions, Suppress => All_Checks);
-                  end;
-
+                  Insert_Actions (N,
+                    Build_Task_Allocate_Block (N, Init_Stmts),
+                    Suppress => All_Checks);
                else
                   Insert_Actions (N, Init_Stmts, Suppress => All_Checks);
                end if;
index 23150c73b9178c8e6e4e4914d0c0c8320e6a614a..48627649a309e529e9223833eb8e1d92a97f8294 100644 (file)
@@ -9187,10 +9187,9 @@ package body Exp_Ch6 is
 
       begin
          if Might_Have_Tasks (Result_Subt) then
-            Actions := New_List;
-            Build_Task_Allocate_Block
-              (Actions, Allocator, Init_Stmts => New_List (Assign));
-            Chain := Activation_Chain_Entity (Last (Actions));
+            Actions :=
+              Build_Task_Allocate_Block (Allocator, New_List (Assign));
+            Chain   := Activation_Chain_Entity (Last (Actions));
          else
             Actions := New_List (Assign);
             Chain   := Empty;
index f23df88a5b81e54704bf72ef6b2b041423bcacd0..636dc6f77032bd588cb3771469867439dec316c1 100644 (file)
@@ -4557,10 +4557,9 @@ package body Exp_Ch9 is
    -- Build_Task_Allocate_Block --
    -------------------------------
 
-   procedure Build_Task_Allocate_Block
-     (Actions    : List_Id;
-      N          : Node_Id;
-      Init_Stmts : List_Id)
+   function Build_Task_Allocate_Block
+     (N          : Node_Id;
+      Init_Stmts : List_Id) return List_Id
    is
       Loc    : constant Source_Ptr := Sloc (N);
       Chain  : constant Entity_Id  :=
@@ -4593,17 +4592,16 @@ package body Exp_Ch9 is
           Handled_Statement_Sequence =>
             Make_Handled_Sequence_Of_Statements (Loc, Init_Stmts),
 
-          Has_Created_Identifier => True,
+          Has_Created_Identifier   => True,
           Is_Task_Allocation_Block => True);
 
-      Append_To (Actions,
+      Set_Activation_Chain_Entity (Block, Chain);
+
+      return New_List (
         Make_Implicit_Label_Declaration (Loc,
           Defining_Identifier => Blkent,
-          Label_Construct     => Block));
-
-      Append_To (Actions, Block);
-
-      Set_Activation_Chain_Entity (Block, Chain);
+          Label_Construct     => Block),
+        Block);
    end Build_Task_Allocate_Block;
 
    -----------------------------------
index 4e5bdcc6434763d6da9a8d5e0111783b97ae2643..4eda90d9ea2fca74fc23db3dbae920bc1e01aa3f 100644 (file)
@@ -103,13 +103,11 @@ package Exp_Ch9 is
    --  Activate_Tasks with this entity as the single parameter is inserted at
    --  the start of the statements of the activator.
 
-   procedure Build_Task_Allocate_Block
-     (Actions    : List_Id;
-      N          : Node_Id;
-      Init_Stmts : List_Id);
-   --  This routine is used in the case of allocators where the designated type
-   --  is a task or contains tasks. In this case, the normal initialize call
-   --  is replaced by:
+   function Build_Task_Allocate_Block
+     (N          : Node_Id;
+      Init_Stmts : List_Id) return List_Id;
+   --  This function is used for allocators where the designated type is a task
+   --  or contains tasks. In this case, the initialization call is replaced by:
    --
    --    blockname : label;
    --    blockname : declare
@@ -130,7 +128,7 @@ package Exp_Ch9 is
    --  to get the task or tasks created and initialized. The expunge call
    --  ensures that any tasks that get created but not activated due to an
    --  exception are properly expunged (it has no effect in the normal case).
-   --  The argument N is the allocator, and Args is the list of arguments for
+   --  The argument N is the allocator, and Init_Stmts is a list containing
    --  the initialization call, constructed by the caller, which uses the
    --  Master_Id of the access type as the _Master parameter, and _Chain
    --  (defined above) as the _Chain parameter.