diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-09-21 23:27:44 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-06 11:11:24 +0200 |
commit | 48d7a599ecd141f7936deff6170dd5199edb2d98 (patch) | |
tree | 67a547747a46db24e6bd4b4345975a4b93835d33 /gcc/ada/contracts.adb | |
parent | 53c32e9d7f01ee350803c9371b8630bf3e4844b7 (diff) | |
download | gcc-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/contracts.adb')
-rw-r--r-- | gcc/ada/contracts.adb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 551e9f3..c440053 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -4176,13 +4176,13 @@ package body Contracts is Helper_Decl := Build_Call_Helper_Decl; Mutate_Ekind (Helper_Id, Ekind (Subp_Id)); - -- Add the helper to the freezing actions of the tagged type + -- Add the helper to the freezing actions of the class-wide type - Append_Freeze_Action (Tagged_Type, Helper_Decl); + Append_Freeze_Action (Class_Wide_Type (Tagged_Type), Helper_Decl); Analyze (Helper_Decl); Helper_Body := Build_Call_Helper_Body; - Append_Freeze_Action (Tagged_Type, Helper_Body); + Append_Freeze_Action (Class_Wide_Type (Tagged_Type), Helper_Body); -- If this helper is built as part of building the DTW at the -- freezing point of its tagged type then we cannot defer |