Commit 6c142b14 by Gary Dismukes Committed by Pierre-Marie de Rodat

[Ada] Unnesting issues with entry families and accept statements

2019-10-10  Gary Dismukes  <dismukes@adacore.com>

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
parent 55160f6c
2019-10-10 Ed Schonberg <schonberg@adacore.com>
2019-10-10 Gary Dismukes <dismukes@adacore.com>
* 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
* 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
......@@ -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.
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment