From: Eric Botcazou Date: Wed, 1 Apr 2026 15:47:56 +0000 (+0200) Subject: ada: Small consistency fixes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc68c4ed0af6acd8a142279575d9c6ed7ec32eee;p=thirdparty%2Fgcc.git ada: Small consistency fixes 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. --- diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 4077a8e17d2..2f653dd123e 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -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 diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 38aafbf7578..843dc173c25 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -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 diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 5ae609c47e4..6d434507d45 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -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, diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 040ffb22204..77e19f905bd 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -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. diff --git a/gcc/ada/exp_ch9.ads b/gcc/ada/exp_ch9.ads index a4354eeec85..3d882f2262d 100644 --- a/gcc/ada/exp_ch9.ads +++ b/gcc/ada/exp_ch9.ads @@ -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; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 1cfe48db4d7..99799431d87 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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;