Object_Definition => New_Occurrence_Of (Typ, Loc));
Set_No_Initialization (Tmp_Decl, True);
- -- If we are within a loop, the temporary will be pushed on the
- -- stack at each iteration. If the aggregate is the expression
- -- for an allocator, it will be immediately copied to the heap
- -- and can be reclaimed at once. We create a transient scope
- -- around the aggregate for this purpose.
-
- if Ekind (Current_Scope) = E_Loop
- and then Nkind (Parent_Node) = N_Allocator
- then
- Establish_Transient_Scope (N, Manage_Sec_Stack => False);
-
-- If the parent is an assignment for which no controlled actions
-- should take place, prevent the temporary from being finalized.
- elsif Nkind (Parent_Node) = N_Assignment_Statement
+ if Nkind (Parent_Node) = N_Assignment_Statement
and then No_Ctrl_Actions (Parent_Node)
then
Mutate_Ekind (Tmp, E_Variable);
-- Establish_Transient_Scope --
-------------------------------
- -- This procedure is called each time a transient block has to be inserted
- -- that is to say for each call to a function with unconstrained or tagged
+ -- This procedure is called when a transient scope has to be inserted in
+ -- the tree to manage the lifetime of temporaries created for a construct,
+ -- most notably for calls to functions with a controlled or unconstrained
-- result. It creates a new scope on the scope stack in order to enclose
-- all transient variables generated.