aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/inline.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-02-11 13:12:53 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-05-23 09:59:07 +0200
commitac243c845a2049c3e302a8ae81a01b53b467a2ff (patch)
treebb4ccd232f17bccf64ed2225947dcb2653227b3b /gcc/ada/inline.adb
parente15ce6502c7b607f2ca0ee178a715d6fc13ac6b6 (diff)
downloadgcc-ac243c845a2049c3e302a8ae81a01b53b467a2ff.zip
gcc-ac243c845a2049c3e302a8ae81a01b53b467a2ff.tar.gz
gcc-ac243c845a2049c3e302a8ae81a01b53b467a2ff.tar.bz2
ada: Fix latent issue in support for protected entries
The problem is that, unlike for protected subprograms, the expansion of cleanups for protected entries is not delayed when they contain package instances with a body, so the cleanups are generated twice and this may yield two finalizers if the secondary stack is used in the entry body. This restores the delaying, which uncovers the missing propagation of the Uses_Sec_Stack flag as is done for protected subprograms, which in turn requires using a Corresponding_Spec field as for protected subprograms. This also gets rid of the Delay_Subprogram_Descriptors flag on entities, whose only remaining use in Expand_Cleanup_Actions was unreachable. The last change is to unconditionally reset the scopes in the case of protected subprograms when they are expanded, as is done in the case of protected entries. This makes it possible to remove the code adjusting the scope on the fly in Cleanup_Scopes but requires a few adjustments. gcc/ada/ * einfo.ads (Delay_Subprogram_Descriptors): Delete. * gen_il-fields.ads (Opt_Field_Enum): Remove Delay_Subprogram_Descriptors. * gen_il-gen-gen_entities.adb (Gen_Entities): Likewise. * gen_il-gen-gen_nodes.adb (N_Entry_Body): Add Corresponding_Spec. * sinfo.ads (Corresponding_Spec): Document new use. (N_Entry_Body): Likewise. * exp_ch6.adb (Expand_Protected_Object_Reference): Be prepared for protected subprograms that have been expanded. * exp_ch7.adb (Expand_Cleanup_Actions): Remove unreachable code. * exp_ch9.adb (Build_Protected_Entry): Add a local variable for the new block and propagate Uses_Sec_Stack from the corresponding spec. (Expand_N_Protected_Body) <N_Subprogram_Body>: Unconditionally reset the scopes of top-level entities in the new body. * inline.adb (Cleanup_Scopes): Do not adjust the scope on the fly. * sem_ch9.adb (Analyze_Entry_Body): Set Corresponding_Spec. * sem_ch12.adb (Analyze_Package_Instantiation): Remove obsolete code setting Delay_Subprogram_Descriptors and tidy up. * sem_util.adb (Scope_Within): Deal with protected subprograms that have been expanded. (Scope_Within_Or_Same): Likewise.
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r--gcc/ada/inline.adb10
1 files changed, 0 insertions, 10 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index 07f806a..b2ff7c9 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -2824,16 +2824,6 @@ package body Inline is
while Present (Elmt) loop
Scop := Node (Elmt);
- if Ekind (Scop) = E_Entry then
- Scop := Protected_Body_Subprogram (Scop);
-
- elsif Is_Subprogram (Scop)
- and then Is_Protected_Type (Underlying_Type (Scope (Scop)))
- and then Present (Protected_Body_Subprogram (Scop))
- then
- Scop := Protected_Body_Subprogram (Scop);
- end if;
-
if Ekind (Scop) = E_Block then
Decl := Parent (Block_Node (Scop));