-- which prompted the generation of the transient block. To resolve
-- this scenario, store the build-in-place call.
- if Scope_Is_Transient and then Node_To_Be_Wrapped = Obj_Decl then
+ if Scope_Is_Transient then
Set_BIP_Initialization_Call (Obj_Def_Id, Res_Decl);
end if;
-- <or>
-- Hook := Obj_Id'Unrestricted_Access;
- if Ekind (Obj_Id) in E_Constant | E_Variable
- and then Present (Last_Aggregate_Assignment (Obj_Id))
- then
- Hook_Insert := Last_Aggregate_Assignment (Obj_Id);
+ -- Similarly if we have a build in place call: we must
+ -- initialize Hook only after the call has happened, otherwise
+ -- Obj_Id will not be initialized yet.
+
+ if Ekind (Obj_Id) in E_Constant | E_Variable then
+ if Present (Last_Aggregate_Assignment (Obj_Id)) then
+ Hook_Insert := Last_Aggregate_Assignment (Obj_Id);
+ elsif Present (BIP_Initialization_Call (Obj_Id)) then
+ Hook_Insert := BIP_Initialization_Call (Obj_Id);
+ else
+ Hook_Insert := Obj_Decl;
+ end if;
-- Otherwise the hook seizes the related object immediately