]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Improve task entry context detection
authorRonan Desplanques <desplanques@adacore.com>
Thu, 21 Nov 2024 09:01:47 +0000 (10:01 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 12 Dec 2024 09:58:00 +0000 (10:58 +0100)
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.

gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb

index a5d69c33b1519015bfa14e4604a9084c9c52cfb5..11f69db21dc2b6873122fbbbd76f04df342d5ce3 100644 (file)
@@ -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.
 
index 16f296523f4cc42edd856a8244e030057860d4eb..1ac76bbd0db97d8cbc4c64b7bcd6aaefb598ac0c 100644 (file)
@@ -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));