https://gcc.gnu.org/g:755b0aad03b7fb4327c71d848e4d64c702eceb4f
commit r16-6600-g755b0aad03b7fb4327c71d848e4d64c702eceb4f Author: Eric Botcazou <[email protected]> Date: Sat Nov 22 15:19:28 2025 +0100 ada: Make Exp_Ch9.Build_Task_Allocate_Block a function 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. Diff: --- gcc/ada/exp_aggr.adb | 13 +++---------- gcc/ada/exp_ch4.adb | 12 +++--------- gcc/ada/exp_ch6.adb | 7 +++---- gcc/ada/exp_ch9.adb | 20 +++++++++----------- gcc/ada/exp_ch9.ads | 14 ++++++-------- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 0a0c857b45ee..24fd5b5f92aa 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -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; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 1c9dc07b4ff3..1d167e01b8c3 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -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; diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 23150c73b917..48627649a309 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -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; diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index f23df88a5b81..636dc6f77032 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -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; ----------------------------------- diff --git a/gcc/ada/exp_ch9.ads b/gcc/ada/exp_ch9.ads index 4e5bdcc64347..4eda90d9ea2f 100644 --- a/gcc/ada/exp_ch9.ads +++ b/gcc/ada/exp_ch9.ads @@ -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.
