]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Small refactoring in Check_Anonymous_Access_Return_With_Tasks
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 26 Jan 2026 08:16:20 +0000 (09:16 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 26 May 2026 08:38:17 +0000 (10:38 +0200)
The procedure uses a custom version of the Might_Have_Tasks predicate, so
this changes it to call the predicate instead.

gcc/ada/ChangeLog:

* sem_ch6.adb (Check_Anonymous_Access_Return_With_Tasks): Declare
Scop as a constant and call the Might_Have_Tasks predicate instead
of using a custom implementation of it.

gcc/ada/sem_ch6.adb

index 514ab6eb6181eeebc0028582d0ed7cd00c85296c..163d666ce104b05a1b8cec0b97a5e34f2d7d5ea0 100644 (file)
@@ -2825,32 +2825,22 @@ package body Sem_Ch6 is
       ----------------------------------------------
 
       procedure Check_Anonymous_Access_Return_With_Tasks is
+         Scop : constant Entity_Id :=
+                  (if Present (Spec_Id) then Spec_Id else Body_Id);
+
          Decl : Node_Id;
-         Scop : Entity_Id;
 
       begin
-         if Present (Spec_Id) then
-            Scop := Spec_Id;
-         else
-            Scop := Body_Id;
-         end if;
-
          if Ekind (Scop) = E_Function
-           and then Ekind (Etype (Scop)) = E_Anonymous_Access_Type
            and then not Is_Thunk (Scop)
+           and then Ekind (Etype (Scop)) = E_Anonymous_Access_Type
+           and then Might_Have_Tasks (Designated_Type (Etype (Scop)))
 
             --  Skip internally built functions which handle the case of
             --  a null access (see Expand_Interface_Conversion)
 
            and then not (Is_Interface (Designated_Type (Etype (Scop)))
                           and then not Comes_From_Source (Parent (Scop)))
-
-           and then (Has_Task (Designated_Type (Etype (Scop)))
-                      or else
-                        (Is_Class_Wide_Type (Designated_Type (Etype (Scop)))
-                           and then
-                         Is_Limited_Record
-                           (Etype (Designated_Type (Etype (Scop))))))
            and then Expander_Active
          then
             Decl := Build_Master_Declaration (Loc);