Even if the declaration of the conditional object is turned into a renaming
during expansion, the conditional object must be finalized when the original
object would have been.
gcc/ada/ChangeLog:
* exp_ch4.adb (Insert_Conditional_Object_Declaration): Create the
Master_Node even if the declaration is turned into a renaming.
-- cannot invoke Process_Transients_In_Expression on it since it is not
-- a transient object (it has the lifetime of the original object).
- if Nkind (Obj_Decl) = N_Object_Declaration
- and then Needs_Finalization (Base_Type (Etype (Obj_Id)))
- then
+ if Needs_Finalization (Base_Type (Etype (Obj_Id))) then
Master_Node_Id := Make_Temporary (Loc, 'N');
Master_Node_Decl :=
Make_Master_Node_Declaration (Loc, Master_Node_Id, Obj_Id);