-- references on this list are illegal due to the visible refinement.
-- BIP_Initialization_Call
--- Defined in constants and variables whose corresponding declaration
--- is wrapped in a transient block and the inital value is provided by
+-- Defined in constants and variables whose initial value is provided by
-- a build-in-place function call. Contains the relocated build-in-place
-- call after the expansion has decoupled the call from the object. This
--- attribute is used by the finalization machinery to insert cleanup code
--- for all additional transient objects found in the transient block.
+-- attribute is used by the finalization machinery to insert the call to
+-- the routine that attaches the object to the finalization master.
-- C_Pass_By_Copy [implementation base type only]
-- Defined in record types. Set if a pragma Convention for the record
-- If the expression is in the context of a simple return statement,
-- possibly through intermediate conditional expressions, we delay
-- expansion until the (immediate) parent is rewritten as a return
- -- statement (or is already the return statement).
+ -- statement (or is already the return statement). Likewise if it is
+ -- in the context of an object declaration that can be optimized.
if not Expansion_Delayed (N) then
declare
end if;
-- If the expansion of the expression has been delayed, we wait for the
- -- rewriting of its parent as an assignment or return statement; when
- -- that's done, we optimize the assignment or the return statement (the
- -- very purpose of the manipulation).
+ -- rewriting of its parent as an assignment statement, or as as return
+ -- statement or as an object declaration; when that's done, we optimize
+ -- the assignment, return or declaration (the purpose of the delaying).
if Expansion_Delayed (N) then
if Nkind (Par) = N_Assignment_Statement then
-- If the expression is in the context of a simple return statement,
-- possibly through intermediate conditional expressions, we delay
-- expansion until the (immediate) parent is rewritten as a return
- -- statement (or is already the return statement). Note that this
- -- deals with the case of the elsif part of the if expression.
+ -- statement (or is already the return statement). Likewise if it is
+ -- in the context of an object declaration that can be optimized.
+ -- Note that this deals with the case of the elsif part of the if
+ -- expression, if it exists.
if not Expansion_Delayed (N) then
declare
end if;
-- If the expansion of the expression has been delayed, we wait for the
- -- rewriting of its parent as an assignment or return statement; when
- -- that's done, we optimize the assignment or the return statement (the
- -- very purpose of the manipulation).
+ -- rewriting of its parent as an assignment statement, or as as return
+ -- statement or as an object declaration; when that's done, we optimize
+ -- the assignment, return or declaration (the purpose of the delaying).
if Expansion_Delayed (N) then
if Nkind (Par) = N_Assignment_Statement then
if Definite and then not Is_OK_Return_Object then
- -- The related object declaration is encased in a transient block
- -- because the build-in-place function call contains at least one
- -- nested function call that produces a controlled transient
- -- temporary:
-
- -- Obj : ... := BIP_Func_Call (Ctrl_Func_Call);
+ Set_Expression (Obj_Decl, Empty);
+ Set_No_Initialization (Obj_Decl);
-- Since the build-in-place expansion decouples the call from the
- -- object declaration, the finalization machinery lacks the context
- -- which prompted the generation of the transient block. To resolve
- -- this scenario, store the build-in-place call.
+ -- object declaration, the finalization machinery needs to know
+ -- when the object is initialized. Store the build-in-place call.
- if Scope_Is_Transient then
- Set_BIP_Initialization_Call (Obj_Def_Id, Res_Decl);
- end if;
-
- Set_Expression (Obj_Decl, Empty);
- Set_No_Initialization (Obj_Decl);
+ Set_BIP_Initialization_Call (Obj_Def_Id, Res_Decl);
-- Park the generated statements if the declaration requires it and
-- is not the node that is wrapped in a transient scope.