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.
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;
-- 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;
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;
-- 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 :=
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;
-----------------------------------
-- 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
-- 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.