-- call wrapper if available.
-- Initialization_Statements
--- Defined in constants and variables. For a composite object coming from
--- source and initialized with an aggregate or a call expanded in place,
+-- Defined in constants and variables. For composite objects coming from
+-- source and (default-)initialized with an aggregate or a function call,
-- points to a compound statement containing the assignment(s). This is
-- used for a couple of purposes: 1) to defer the initialization to the
-- freeze point if an address clause or a delayed aspect is present for
-------------------------------
procedure Default_Initialize_Object (After : Node_Id) is
+ Marker : constant Node_Id := Next (After);
+
Init_Expr : Node_Id;
Init_Stmts : List_Id;
Init_Stmts := Build_Default_Initialization (N, Typ, Def_Id);
end if;
- -- Insert the whole initialization sequence into the tree. If the
- -- object has a delayed freeze, as will be the case when it has
- -- aspect specifications, the initialization sequence is part of
- -- the freeze actions.
+ -- Insert the whole initialization sequence into the tree. Park the
+ -- generated statements if the declaration requires it and is not the
+ -- node that is wrapped in a transient scope.
if Present (Init_Stmts) then
- if Has_Delayed_Freeze (Def_Id) then
- Append_Freeze_Actions (Def_Id, Init_Stmts);
- else
- Insert_Actions_After (After, Init_Stmts);
+ Insert_Actions_After (After, Init_Stmts);
+
+ if not Special_Ret_Obj
+ and then Needs_Initialization_Statements (N)
+ and then not (Scope_Is_Transient and then N = Node_To_Be_Wrapped)
+ then
+ Move_To_Initialization_Statements (N, Marker);
end if;
end if;
end Default_Initialize_Object;