diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-12-20 17:39:10 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-06 11:11:28 +0200 |
commit | 8d613b26d3d9d388dc85f95a035d4972dc3bc1ba (patch) | |
tree | e9dafb7facce6d38802d45717054cc5882a2fd25 /gcc/ada/einfo.ads | |
parent | 3b2f2aac29a881c5b68bb3d42bd9729545e82448 (diff) | |
download | gcc-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/einfo.ads')
-rw-r--r-- | gcc/ada/einfo.ads | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 2496400..6f563d5 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -1305,15 +1305,13 @@ package Einfo is -- type. Empty for access-to-subprogram types. Empty for access types -- whose designated type does not need finalization actions. --- Finalization_Master_Node_Or_Object +-- Finalization_Master_Node -- Defined in variables and constants that require finalization actions. -- The field contains the entity of an object (called a Master_Node) that -- contains the address of the finalizable object, along with an access -- value denoting the finalizable object's finalization procedure. The -- Master_Node may be attached to a finalization list associated with -- either the global scope or some dynamic scope (block or subprogram). --- Conversely, for a Master_Node entity, the field contains the entity --- of the finalizable object. -- Finalize_Storage_Only [base type only] -- Defined in all types. Set on direct controlled types to which a @@ -5304,7 +5302,7 @@ package Einfo is -- Related_Type (constants only) -- Initialization_Statements -- BIP_Initialization_Call - -- Finalization_Master_Node_Or_Object + -- Finalization_Master_Node -- Last_Aggregate_Assignment -- Activation_Record_Component -- Encapsulating_State (constants only) @@ -6191,7 +6189,7 @@ package Einfo is -- Related_Type -- Initialization_Statements -- BIP_Initialization_Call - -- Finalization_Master_Node_Or_Object + -- Finalization_Master_Node -- Last_Aggregate_Assignment -- Activation_Record_Component -- Encapsulating_State |