https://gcc.gnu.org/g:8f931770a52e208b0f66066e8c6e09214597655f
commit r15-6153-g8f931770a52e208b0f66066e8c6e09214597655f Author: Ronan Desplanques <desplanq...@adacore.com> Date: Thu Nov 21 10:01:47 2024 +0100 ada: Improve task entry context detection Access parameters are not allowed in specifications of task entries. Before this patch, the compiler failed to detect that case in accept statements that were not directly in their task body's scopes. This patch fixes this issue. gcc/ada/ChangeLog: * sem_ch3.adb (Access_Definition): Remove test for task entry context. * sem_ch6.adb (Process_Formals): Add improved test for task entry context. Diff: --- gcc/ada/sem_ch3.adb | 7 ------- gcc/ada/sem_ch6.adb | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index a5d69c33b151..11f69db21dc2 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -761,13 +761,6 @@ package body Sem_Ch3 is Enclosing_Prot_Type : Entity_Id := Empty; begin - if Is_Entry (Current_Scope) - and then Is_Task_Type (Etype (Scope (Current_Scope))) - then - Error_Msg_N ("task entries cannot have access parameters", N); - return Empty; - end if; - -- Ada 2005: For an object declaration the corresponding anonymous -- type is declared in the current scope. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 16f296523f4c..1ac76bbd0db9 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -13144,6 +13144,16 @@ package body Sem_Ch6 is -- An access formal type else + if Nkind (Parent (T)) = N_Accept_Statement + or else (Nkind (Parent (T)) = N_Entry_Declaration + and then Nkind (Context) = N_Task_Definition) + then + Error_Msg_N + ("task entries cannot have access parameters", + Parameter_Type (Param_Spec)); + return; + end if; + Formal_Type := Access_Definition (Related_Nod, Parameter_Type (Param_Spec));