+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
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));
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;