]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Small consistency fixes
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 1 Apr 2026 15:47:56 +0000 (17:47 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 2 Jun 2026 08:42:22 +0000 (10:42 +0200)
Build_Activation_Chain_Entity and Build_Master_Entity from Exp_Ch9 are very
similar but the former takes a Node while the latter takes an Entity.  This
aligns the latter with the former.  No functional changes.

gcc/ada/ChangeLog:

* exp_aggr.adb (Build_Array_Aggr_Code): Adjust actual parameter in
the call to Build_Master_Entity.
* exp_ch3.adb (Expand_N_Full_Type_Declaration): Likewise.
(Expand_N_Object_Declaration): Likewise.
(Expand_Previous_Access_Type): Likewise.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Anonymous_Context):
Likewise.
(Make_Build_In_Place_Iface_Call_In_Allocator): Likewise.
(Make_Build_In_Place_Iface_Call_In_Anonymous_Context): Likewise.
* sem_ch3.adb (Access_Definition): Likewise.
(Access_Type_Declaration): Likewise.
* exp_ch9.ads (Build_Activation_Chain_Entity): Tweak description.
(Build_Master_Entity): Change parameter and tweak description.
* exp_ch9.adb (Build_Master_Entity): Change parameter and adjust.

gcc/ada/exp_aggr.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_ch9.ads
gcc/ada/sem_ch3.adb

index 4077a8e17d2641e7b1e01f03f027bb7101980ec9..2f653dd123e08ec350aebc96fac4043961e03d69 100644 (file)
@@ -2060,7 +2060,7 @@ package body Exp_Aggr is
       --  in-place functions are called in the expanded code.
 
       if Nkind (Parent (N)) = N_Object_Declaration and then Has_Task (Typ) then
-         Build_Master_Entity (Defining_Identifier (Parent (N)));
+         Build_Master_Entity (Parent (N));
       end if;
 
       --  STEP 1: Process component associations
index 38aafbf7578827fd67d58d3032dabefdb18be0e7..843dc173c25bc524a32958fcecb69c4b39990250 100644 (file)
@@ -6866,7 +6866,7 @@ package body Exp_Ch3 is
          --  for such a type.
 
          if Has_Task (Desig_Typ) then
-            Build_Master_Entity (Ptr_Typ);
+            Build_Master_Entity (N);
             Build_Master_Renaming (Ptr_Typ);
 
          --  Create a class-wide master because a Master_Id must be generated
@@ -6885,7 +6885,7 @@ package body Exp_Ch3 is
          elsif not Is_Param_Block_Component_Type (Ptr_Typ)
            and then Is_Limited_Class_Wide_Type (Desig_Typ)
          then
-            Build_Master_Entity (Ptr_Typ);
+            Build_Master_Entity (N);
             Build_Master_Renaming (Ptr_Typ);
          end if;
       end Build_Master;
@@ -6956,7 +6956,7 @@ package body Exp_Ch3 is
                   --  Ensure that the record or array type have a _master
 
                   if First then
-                     Build_Master_Entity (Def_Id);
+                     Build_Master_Entity (N);
                      Build_Master_Renaming (Typ);
                      M_Id := Master_Id (Typ);
 
@@ -7874,7 +7874,7 @@ package body Exp_Ch3 is
          Build_Activation_Chain_Entity (N);
 
          if Has_Task (Typ) or else Has_BIP_Init_Expr then
-            Build_Master_Entity (Def_Id);
+            Build_Master_Entity (N);
          end if;
       end if;
 
@@ -9567,7 +9567,7 @@ package body Exp_Ch3 is
          then
             --  Ensure that the designated type has a master
 
-            Build_Master_Entity (Def_Id);
+            Build_Master_Entity (Parent (Def_Id));
 
             --  Private and incomplete types complicate the insertion of master
             --  renamings because the access type may precede the full view of
index 5ae609c47e489df2cbde910f69de14e65c1ba450..6d434507d45f16bea52034759c118c6e26309888 100644 (file)
@@ -8982,7 +8982,7 @@ package body Exp_Ch6 is
 
             if Has_Tasks then
                Build_Activation_Chain_Entity (Temp_Decl);
-               Build_Master_Entity (Temp_Id);
+               Build_Master_Entity (Temp_Decl);
             end if;
 
             Make_Build_In_Place_Call_In_Object_Declaration
@@ -9580,7 +9580,7 @@ package body Exp_Ch6 is
       Insert_Action (Allocator, Tmp_Decl);
       Expander_Mode_Restore;
 
-      Build_Master_Entity (Anon_Type);
+      Build_Master_Entity (Tmp_Decl);
       Build_Master_Renaming (Anon_Type);
 
       Make_Build_In_Place_Call_In_Allocator
@@ -9638,7 +9638,7 @@ package body Exp_Ch6 is
       Expander_Mode_Restore;
 
       Build_Activation_Chain_Entity (Tmp_Decl);
-      Build_Master_Entity (Tmp_Id);
+      Build_Master_Entity (Tmp_Decl);
 
       Make_Build_In_Place_Iface_Call_In_Object_Declaration
         (Obj_Decl      => Tmp_Decl,
index 040ffb222046ab3267afdb7df6cf56c5e5878c12..77e19f905bdc388f3223c5c2faf1eeb133f11cf7 100644 (file)
@@ -3033,13 +3033,11 @@ package body Exp_Ch9 is
    -- Build_Master_Entity --
    -------------------------
 
-   procedure Build_Master_Entity (Obj_Or_Typ : Entity_Id) is
-      Loc        : constant Source_Ptr := Sloc (Obj_Or_Typ);
+   procedure Build_Master_Entity (N : Node_Id) is
       Context    : Node_Id;
       Context_Id : Entity_Id;
       Decl       : Node_Id;
       Decls      : List_Id;
-      Par        : Node_Id;
 
    begin
       --  No action needed if the run-time has no tasking support
@@ -3048,18 +3046,12 @@ package body Exp_Ch9 is
          return;
       end if;
 
-      if Is_Itype (Obj_Or_Typ) then
-         Par := Associated_Node_For_Itype (Obj_Or_Typ);
-      else
-         Par := Parent (Obj_Or_Typ);
-      end if;
-
       --  When creating a master for a record component which is either a task
       --  or access-to-task, the enclosing record is the master scope and the
       --  proper insertion point is the component list.
 
       if Is_Record_Type (Current_Scope) then
-         Context    := Par;
+         Context    := N;
          Context_Id := Current_Scope;
          Decls      := List_Containing (Context);
 
@@ -3068,7 +3060,7 @@ package body Exp_Ch9 is
       --  return statement.
 
       else
-         Find_Enclosing_Context (Par, Context, Context_Id, Decls);
+         Find_Enclosing_Context (N, Context, Context_Id, Decls);
       end if;
 
       pragma Assert (not Is_Finalizer (Context_Id));
@@ -3079,7 +3071,7 @@ package body Exp_Ch9 is
          return;
       end if;
 
-      Decl := Build_Master_Declaration (Loc);
+      Decl := Build_Master_Declaration (Sloc (N));
 
       --  The master is inserted at the start of the declarative list of the
       --  context.
index a4354eeec858d73e765893957371d9a254979523..3d882f2262d64d35494d7ad184f4fe825f060f86 100644 (file)
@@ -37,11 +37,9 @@ package Exp_Ch9 is
    --  protected subprogram.
 
    procedure Build_Activation_Chain_Entity (N : Node_Id);
-   --  Given a declaration N of an object that is a task, or contains tasks
-   --  (other than allocators to tasks) this routine ensures that an activation
-   --  chain has been declared in the appropriate scope, building the required
-   --  declaration for the chain variable if not. The name of this variable
-   --  is always _Chain and it is accessed by name.
+   --  Given a construct N that involves tasks (other than allocators to tasks)
+   --  create a _Chain entity in the appropriate scope to be used as activation
+   --  chain if there is not already one.
 
    function Build_Call_With_Task (N : Node_Id; E : Entity_Id) return Node_Id;
    --  N is a node representing the name of a task or an access to a task.
@@ -56,11 +54,11 @@ package Exp_Ch9 is
    --  For targets where tasks or tasking hierarchies are prohibited, generate:
    --      _Master : constant Integer := Library_Task_Level;
 
-   procedure Build_Master_Entity (Obj_Or_Typ : Entity_Id);
-   --  Given the name of an object or a type which is either a task, contains
-   --  tasks or designates tasks, create a _Master in the appropriate scope
-   --  which captures the value of Current_Master. Mark the nearest enclosing
-   --  body or block as being a task master.
+   procedure Build_Master_Entity (N : Node_Id);
+   --  Given a construct N that involves or designates tasks, create a _Master
+   --  entity in the appropriate scope if there is not already one, which will
+   --  capture the value of Current_Master. Mark the nearest enclosing body or
+   --  block as being a task master.
 
    function Build_Master_Renaming_Declaration
      (Ptr_Typ : Entity_Id;
index 1cfe48db4d745d63d8ceb0659ca861308f434014..99799431d87eb6e1a08c2ddcf90208d8849a76ac 100644 (file)
@@ -956,7 +956,7 @@ package body Sem_Ch3 is
          if Is_Limited_Record (Desig_Type)
            and then Is_Class_Wide_Type (Desig_Type)
          then
-            Build_Master_Entity (Defining_Identifier (Related_Nod));
+            Build_Master_Entity (Related_Nod);
             Build_Master_Renaming (Anon_Type);
 
          --  Similarly, if the type is an anonymous access that designates
@@ -965,7 +965,7 @@ package body Sem_Ch3 is
          elsif Has_Task (Desig_Type)
            and then Comes_From_Source (Related_Nod)
          then
-            Build_Master_Entity (Defining_Identifier (Related_Nod));
+            Build_Master_Entity (Related_Nod);
             Build_Master_Renaming (Anon_Type);
          end if;
       end if;
@@ -1385,7 +1385,7 @@ package body Sem_Ch3 is
             if From_Limited_With (Entity (S))
               and then not Is_Class_Wide_Type (Entity (S))
             then
-               Build_Master_Entity (T);
+               Build_Master_Entity (Def);
                Build_Master_Renaming (T);
             end if;