aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch7.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-12-20 17:39:10 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-06 11:11:28 +0200
commit8d613b26d3d9d388dc85f95a035d4972dc3bc1ba (patch)
treee9dafb7facce6d38802d45717054cc5882a2fd25 /gcc/ada/exp_ch7.ads
parent3b2f2aac29a881c5b68bb3d42bd9729545e82448 (diff)
downloadgcc-8d613b26d3d9d388dc85f95a035d4972dc3bc1ba.zip
gcc-8d613b26d3d9d388dc85f95a035d4972dc3bc1ba.tar.gz
gcc-8d613b26d3d9d388dc85f95a035d4972dc3bc1ba.tar.bz2
ada: Rework processing of special objects needing finalization
This reworks the processing of special objects needing finalization in the new implementation. These special objects, i.e. return object in extended return statements and transient objects, cannot be automatically handled by the post-processing phase because they have additional requirements, either conditional finalization for the former or immediate finalization for the latter and, therefore, a specific processing during expansion is needed for them before the post-processing phase can complete the work. The previous scheme used to do minimal processing during expansion, leaving the bulk of the work to the post-processing phase. Unfortunately this scheme turned out not to be stable for Expression_With_Actions nodes under copying by means of New_Copy_Tree or equivalent devices. The new scheme moves a bit more processing to the expansion, namely the generation of the attachment to the master node, whose result can then be naturally copied by New_Copy_Tree. A side effect is to further simplify the implementation of Build_Finalizer in Exp_Ch7, which has one fewer special case to deal with. gcc/ada/ * einfo.ads (Finalization_Master_Node_Or_Object): Rename into... (Finalization_Master_Node): ...this and adjust description. * exp_ch4.adb (Process_Transient_In_Expression): Attach the object to its master node here. * exp_ch7.ads (Attach_Object_To_Master_Node): New declaration. * exp_ch7.adb (Attach_Object_To_Master_Node): New procedure. (Build_Finalizer.Process_Declarations): Examine the type of a variable to spot master nodes. (Build_Finalizer.Process_Object_Declaration): Look only at the object and deal specifically with the case of a master node. (Build_Finalizer.Build_BIP_Cleanup_Stmts): Move to child function of Attach_Object_To_Master_Node. (Build_Finalizer.Make_Address_For_Finalize): Move to... (Insert_Actions_In_Scope_Around.Process_Transient_In_Scope): Attach the object to its master node here. (Make_Address_For_Finalize): ...here. (Make_Master_Node_Declaration): Adjust to above renaming and set Finalization_Master_Node only on the object. (Make_Suppress_Object_Finalize_Call): Adjust to above renaming and attach the object to its master node here. * exp_util.adb (Requires_Cleanup_Actions): Examine the type of a variable to spot master nodes. * gen_il-fields.ads (Opt_Field_Enum): Adjust to above renaming. * gen_il-gen-gen_entities.adb (Allocatable_Kind): Likewise. * rtsfind.ads (RE_Id): Add RE_Chain_Node_To_Master. (RE_Unit_Table): Add entry for RE_Chain_Node_To_Master. * libgnat/s-finpri.ads (Chain_Node_To_Master): New declaration. * libgnat/s-finpri.adb (Chain_Node_To_Master): New procedure. (Attach_Object_To_Master): Call it. (Finalize_Master): Do not raise Program_Error on null addresses. (Finalize_Object): Add assertion that the address is not null.
Diffstat (limited to 'gcc/ada/exp_ch7.ads')
-rw-r--r--gcc/ada/exp_ch7.ads7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch7.ads b/gcc/ada/exp_ch7.ads
index c606bb9..97fea23 100644
--- a/gcc/ada/exp_ch7.ads
+++ b/gcc/ada/exp_ch7.ads
@@ -35,6 +35,13 @@ package Exp_Ch7 is
-- Finalization Management --
-----------------------------
+ procedure Attach_Object_To_Master_Node
+ (Obj_Decl : Node_Id;
+ Master_Node : Entity_Id);
+ -- Generate code to attach an object denoted by its declaration Obj_Decl
+ -- to a master node denoted by Master_Node. The code is inserted after
+ -- the object is initialized.
+
procedure Build_Anonymous_Master (Ptr_Typ : Entity_Id);
-- Build a finalization master for an anonymous access-to-controlled type
-- denoted by Ptr_Typ. The master is inserted in the declarations of the