From 6c142b14a07b166fcb2809cd3c3fcd59a748ce7e Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Thu, 10 Oct 2019 15:25:08 +0000 Subject: [PATCH] [Ada] Unnesting issues with entry families and accept statements 2019-10-10 Gary Dismukes gcc/ada/ * sem_util.adb (Enclosing_Subprogram): Handle the case of E_Entry_Family, returning the entry family's associated Protected_Body_Subprogram (as was already done for E_Entry). * exp_ch9.adb (Expand_N_Accept_Statement): Call Reset_Scopes_To on the block created for an accept statement to reset the scopes of any local entities to the block scope. From-SVN: r276830 --- gcc/ada/ChangeLog | 14 ++++++++------ gcc/ada/exp_ch9.adb | 7 +++++++ gcc/ada/sem_util.adb | 12 ++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) rewrite gcc/ada/ChangeLog (99%) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog dissimilarity index 99% index c5e3f820d96..9cf51728022 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,6 +1,8 @@ -2019-10-10 Ed Schonberg - - * sem_ch12.adb (Analyze_Formal_Package_Declaration): Propagate - an aspect specification for Abstract_State from generic package - to formal package, so that it is available when analyzing the - constructed formal. \ No newline at end of file +2019-10-10 Gary Dismukes + + * sem_util.adb (Enclosing_Subprogram): Handle the case of + E_Entry_Family, returning the entry family's associated + Protected_Body_Subprogram (as was already done for E_Entry). + * exp_ch9.adb (Expand_N_Accept_Statement): Call Reset_Scopes_To + on the block created for an accept statement to reset the scopes + of any local entities to the block scope. \ No newline at end of file diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 99bd8d211cb..720c1a9a237 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -6624,6 +6624,13 @@ package body Exp_Ch9 is Declarations => Declarations (N), Handled_Statement_Sequence => Build_Accept_Body (N)); + -- Reset the Scope of local entities associated with the accept + -- statement (that currently reference the entry scope) to the + -- block scope, to avoid having references to the locals treated + -- as up-level references. + + Reset_Scopes_To (Block, Blkent); + -- For the analysis of the generated declarations, the parent node -- must be properly set. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 95699199e3f..f4885735f35 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -6997,17 +6997,17 @@ package body Sem_Util is elsif Ekind_In (Dyn_Scop, E_Block, E_Loop, E_Return_Statement) then return Enclosing_Subprogram (Dyn_Scop); - elsif Ekind (Dyn_Scop) = E_Entry then + elsif Ekind_In (Dyn_Scop, E_Entry, E_Entry_Family) then - -- For a task entry, return the enclosing subprogram of the - -- task itself. + -- For a task entry or entry family, return the enclosing subprogram + -- of the task itself. if Ekind (Scope (Dyn_Scop)) = E_Task_Type then return Enclosing_Subprogram (Dyn_Scop); - -- A protected entry is rewritten as a protected procedure which is - -- the desired enclosing subprogram. This is relevant when unnesting - -- a procedure local to an entry body. + -- A protected entry or entry family is rewritten as a protected + -- procedure which is the desired enclosing subprogram. This is + -- relevant when unnesting a procedure local to an entry body. else return Protected_Body_Subprogram (Dyn_Scop); -- 2.11.4.GIT