From ad8adad11752db7a98fce95d9090f4c6fbb849b7 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Tue, 17 Jul 2018 08:05:29 +0000 Subject: [PATCH] [Ada] Fix unnesting issues involving tasks 2018-07-17 Ed Schonberg 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 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/sem_util.adb | 27 +++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b322861a246..294602ee19a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-07-17 Ed Schonberg + + * 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 * sem_prag.adb (Has_Visible_State): Do not consider generic formals diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 097739270dc..3b142521da9 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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; -- 2.30.2