Commit ad8adad1 by Ed Schonberg Committed by Pierre-Marie de Rodat

[Ada] Fix unnesting issues involving tasks

2018-07-17  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_util.adb (Enclosing_Subprogram): Handle properly entries, and
	synchronized types that are completions of limited types or private
	extensions.
	(Scope_Within): Handle properly accept statements in task bodies.

From-SVN: r262769
parent 8d45ce77
2018-07-17 Ed Schonberg <schonberg@adacore.com>
* sem_util.adb (Enclosing_Subprogram): Handle properly entries, and
synchronized types that are completions of limited types or private
extensions.
(Scope_Within): Handle properly accept statements in task bodies.
2018-07-17 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Has_Visible_State): Do not consider generic formals
......
......@@ -6906,17 +6906,21 @@ package body Sem_Util is
elsif Ekind (Dynamic_Scope) = E_Subprogram_Body then
return Corresponding_Spec (Parent (Parent (Dynamic_Scope)));
elsif Ekind (Dynamic_Scope) = E_Block
or else Ekind (Dynamic_Scope) = E_Return_Statement
elsif Ekind_In (Dynamic_Scope, E_Block, E_Return_Statement, E_Entry)
then
return Enclosing_Subprogram (Dynamic_Scope);
elsif Ekind (Dynamic_Scope) = E_Task_Type then
return Get_Task_Body_Procedure (Dynamic_Scope);
elsif Ekind (Dynamic_Scope) = E_Limited_Private_Type
-- The scope may appear as a private type or as a private extension
-- whose completion is a task or protected type.
elsif Ekind_In (Dynamic_Scope,
E_Limited_Private_Type, E_Record_Type_With_Private)
and then Present (Full_View (Dynamic_Scope))
and then Ekind (Full_View (Dynamic_Scope)) = E_Task_Type
and then Ekind_In (Full_View (Dynamic_Scope),
E_Task_Type, E_Protected_Type)
then
return Get_Task_Body_Procedure (Full_View (Dynamic_Scope));
......@@ -23994,6 +23998,21 @@ package body Sem_Util is
if Curr = Outer then
return True;
-- A selective accept body appears within a task type, but the
-- enclosing subprogram is the procedure of the task body.
elsif Ekind (Curr) = E_Task_Type
and then Outer = Task_Body_Procedure (Curr)
then
return True;
-- Ditto for the body of a protected operation.
elsif Is_Subprogram (Curr)
and then Outer = Protected_Body_Subprogram (Curr)
then
return True;
end if;
end loop;
......
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