aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/einfo.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-09-21 23:27:44 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-05-06 11:11:24 +0200
commit48d7a599ecd141f7936deff6170dd5199edb2d98 (patch)
tree67a547747a46db24e6bd4b4345975a4b93835d33 /gcc/ada/einfo.ads
parent53c32e9d7f01ee350803c9371b8630bf3e4844b7 (diff)
downloadgcc-48d7a599ecd141f7936deff6170dd5199edb2d98.zip
gcc-48d7a599ecd141f7936deff6170dd5199edb2d98.tar.gz
gcc-48d7a599ecd141f7936deff6170dd5199edb2d98.tar.bz2
ada: Partial implementation of redesign of support for object finalization
This set of changes is a partial reimplemention of the support for Ada finalization in the GNAT compiler and run-time library, based on the redesign done by Hristian Kirtchev in February 2022. It only affects the scope-based finalization of objects and does not touch the support for finalization of dynamically allocated objects. It also does not modify the internal architecture of this support in the front-end but only changes its output, i.e. the expanded code. In other words, the code-based dispatching scheme in finalizers and the hook-based approach for transient objects are replaced by finalization scope masters and master nodes, which maintain a list of objects needing finalization, but the expansion of the code that builds these masters is still performed mainly during a dedicated post-processing phase. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add s-finpri$(objext). * contracts.adb (Add_Call_Helper): Append freeze actions to the class-wide type rather than the specific tagged type. * einfo.ads (Finalization_Master_Node_Or_Node): Document. (Status_Flag_Or_Transient_Decl): Remove. * exp_attr.adb (Expand_N_Attribute_Reference) <Address>: Do not adjust a return object of a class-wide interface type. * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Add test that Finalize_Address is not already present as a condition for calling Make_Finalize_Address_Body. (Expand_Freeze_Record_Type): Call Make_Finalize_Address_Body for class-wide types of both regular tagged types and interface types. * exp_ch4.adb (Process_Transients_In_Expression): Replace the use of hooks with the use of master nodes. * exp_ch6.adb (Build_Flag_For_Function): Delete. (Expand_N_Extended_Return_Statement): Create a master node for the return object if it does not exist. At the end of the statement, generate a call to Suppress_Object_Finalize. (Expand_Non_Function_Return): Likewise just before the return. * exp_ch7.ads (Make_Master_Node_Declaration): Declare. (Make_Suppress_Object_Finalize_Call): Likewise. * exp_ch7.adb (Build_Finalization_Master): Defer generating the call to Set_Finalize_Address until freezing if the Finalize_Address procedure has not been analyzed yet. (Build_Finalizer): Reimplement the expansion using a finalization scope master per finalizer. (Insert_Actions_In_Scope_Around): Replace finalization hooks by master nodes and calls to the Finalize_Object. (Make_Master_Node_Declaration): New procedure. (Make_Suppress_Object_Finalize_Call): Likewise. * exp_util.ads (Build_Transient_Object_Statements): Delete. * exp_util.adb (Build_Transient_Object_Statements): Likewise. (Requires_Cleanup_Actions): Remove obsolete code and return true for master nodes. * gen_il-fields.ads (Opt_Field_Enum): Add Finalization_Master_Node_Or_Object and remove Status_Flag_Or_Transient_Decl. * gen_il-gen-gen_entities.adb (Allocatable_Kind): Likewise. * rtsfind.ads (RTU_Id): Add System_Finalization_Primitives. (RE_Id): Add entities of System_Finalization_Primitives. (RE_Unit_Table): Add entries for them. * sem_ch3.adb (Analyze_Object_Declaration): For an array whose type has an unconstrained first subtype and a controlled component, set the Is_Constr_Array_Subt_With_Bounds flag. * libgnat/s-finpri.ads: New file. * libgnat/s-finpri.adb: Likewise.
Diffstat (limited to 'gcc/ada/einfo.ads')
-rw-r--r--gcc/ada/einfo.ads23
1 files changed, 12 insertions, 11 deletions
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 4870684..2496400 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -1305,6 +1305,16 @@ 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
+-- 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
-- valid Finalize_Storage_Only pragma applies. This flag is also set on
@@ -4513,15 +4523,6 @@ package Einfo is
-- from another predicate but does not add a predicate of its own, the
-- expression may consist of the above xxxPredicate call on its own.
--- Status_Flag_Or_Transient_Decl
--- Defined in constant, loop, and variable entities. Applies to objects
--- that require special treatment by the finalization machinery, such as
--- extended return objects, conditional expression results, and objects
--- inside N_Expression_With_Actions nodes. The attribute contains the
--- entity of a flag which specifies a particular behavior over a region
--- of the extended return for the return objects, or the declaration of a
--- hook object for conditional expressions and N_Expression_With_Actions.
-
-- Storage_Size_Variable [implementation base type only]
-- Defined in access types and task type entities. This flag is set
-- if a valid and effective pragma Storage_Size applies to the base
@@ -5294,7 +5295,6 @@ package Einfo is
-- Esize
-- Extra_Accessibility (constants only)
-- Alignment
- -- Status_Flag_Or_Transient_Decl
-- Actual_Subtype
-- Renamed_Object
-- Renamed_Entity $$$
@@ -5304,6 +5304,7 @@ package Einfo is
-- Related_Type (constants only)
-- Initialization_Statements
-- BIP_Initialization_Call
+ -- Finalization_Master_Node_Or_Object
-- Last_Aggregate_Assignment
-- Activation_Record_Component
-- Encapsulating_State (constants only)
@@ -6174,7 +6175,6 @@ package Einfo is
-- Esize
-- Extra_Accessibility
-- Alignment
- -- Status_Flag_Or_Transient_Decl (transient object only)
-- Unset_Reference
-- Actual_Subtype
-- Renamed_Object
@@ -6191,6 +6191,7 @@ package Einfo is
-- Related_Type
-- Initialization_Statements
-- BIP_Initialization_Call
+ -- Finalization_Master_Node_Or_Object
-- Last_Aggregate_Assignment
-- Activation_Record_Component
-- Encapsulating_State