diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-03-03 20:34:09 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-26 09:29:16 +0200 |
commit | 0c1d2675f964808b042b9fafae2c540933bb8269 (patch) | |
tree | ec0c0ba62718895a80ef4a690fc50de54ffc3b1c /gcc/ada/einfo.ads | |
parent | 9df0c1198ecba478ac27d28765224412ee6606e9 (diff) | |
download | gcc-0c1d2675f964808b042b9fafae2c540933bb8269.zip gcc-0c1d2675f964808b042b9fafae2c540933bb8269.tar.gz gcc-0c1d2675f964808b042b9fafae2c540933bb8269.tar.bz2 |
ada: Fix missing finalization in library-level instance body
This extends the delaying mechanism present in the cases where the instance
is not at library level, so as to wait until after the instantiation of the
body is performed, before generating the finalizer of the compilation unit.
gcc/ada/
* einfo.ads (Delay_Cleanups): Document new usage.
* exp_ch7.ads (Build_Finalizer): New declaration.
* exp_ch7.adb (Build_Finalizer.Process_Declarations): Do not treat
library-level package instantiations specially.
(Build_Finalizer): Return early for package bodies and specs that
are not compilation units instead of using a more convoluted test.
(Expand_N_Package_Body): Do not build a finalizer if Delay_Cleanups
is set on the defining entity.
(Expand_N_Package_Declaration): Likewise.
* inline.ads (Pending_Body_Info): Reorder and add Fin_Scop.
(Add_Pending_Instantiation): Add Fin_Scop parameter.
* inline.adb (Add_Pending_Instantiation): Likewise and copy it into
the Pending_Body_Info appended to Pending_Instantiations.
(Add_Scope_To_Clean): Change parameter name to Scop and remove now
irrelevant processing.
(Cleanup_Scopes): Deal with scopes that are package specs or bodies.
(Instantiate_Body): For package instantiations, deal specially with
scopes that are package bodies and with scopes that are dynamic.
Pass the resulting scope to Add_Scope_To_Clean directly.
* sem_ch12.adb (Analyze_Package_Instantiation): In the case where a
body is needed, compute the enclosing finalization scope and pass it
in the call to Add_Pending_Instantiation.
(Inline_Instance_Body): Adjust aggregate passed in the calls to
Instantiate_Package_Body.
(Load_Parent_Of_Generic): Likewise.
Diffstat (limited to 'gcc/ada/einfo.ads')
-rw-r--r-- | gcc/ada/einfo.ads | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 7dc2bd1..ef5201a 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -864,12 +864,12 @@ package Einfo is -- and IN OUT parameters in the absence of errors). -- Delay_Cleanups --- Defined in entities that have finalization lists (subprograms --- blocks, and tasks). Set if there are pending generic body --- instantiations for the corresponding entity. If this flag is --- set, then generation of cleanup actions for the corresponding --- entity must be delayed, since the insertion of the generic body --- may affect cleanup generation (see Inline for further details). +-- Defined in entities that have finalization lists (subprograms, blocks +-- and tasks) or finalizers (package specs and bodies). Set if there are +-- pending package body instantiations for the corresponding entity. If +-- it is set, then generation of cleanup actions for the corresponding +-- entity must be delayed, since the insertion of the package bodies may +-- affect cleanup generation (see Inline for further details). -- Delta_Value -- Defined in fixed and decimal types. Points to a universal real |