https://gcc.gnu.org/g:ebff38ebd2aa99adc20cbbfa7a53ea75fcf18edd
commit r17-5356-gebff38ebd2aa99adc20cbbfa7a53ea75fcf18edd Author: Eric Botcazou <[email protected]> Date: Mon Oct 19 16:03:52 2026 +0200 Ada: Replace uses of Sem_Util.Within_Init_Proc by Exp_Util.Inside_Init_Proc The two functions implement the same predicate. gcc/ada/ PR ada/127994 * checks.adb (Build_Discriminant_Checks): Replace all calls to Sem_Util.Within_Init_Proc by calls to Exp_Util.Inside_Init_Proc. * exp_aggr.adb (Build_Record_Aggr_Code): Likewise. * exp_ch2.adb (Expand_Discriminant): Likewise. * exp_ch7.adb (Establish_Transient_Scope): Likewise. * exp_pakd.adb (Expand_Bit_Packed_Element_Set): Likewise. * exp_util.adb (Expand_Subtype_From_Expr): Likewise. * sem_ch3.adb (Analyze_Subtype_Declaration): Likewise. (Build_Discriminated_Subtype): Likewise. * sem_util.adb (Normalize_Actuals): Likewise. (Within_Init_Proc): Delete. * sem_util.ads (Within_Init_Proc): Likewise. Diff: --- gcc/ada/checks.adb | 4 ++-- gcc/ada/exp_aggr.adb | 4 ++-- gcc/ada/exp_ch2.adb | 2 +- gcc/ada/exp_ch7.adb | 2 +- gcc/ada/exp_pakd.adb | 6 ++---- gcc/ada/exp_util.adb | 2 +- gcc/ada/sem_ch3.adb | 4 ++-- gcc/ada/sem_util.adb | 22 +--------------------- gcc/ada/sem_util.ads | 3 --- 9 files changed, 12 insertions(+), 37 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 6f25f23f99a3..7de13ff50683 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -4146,7 +4146,7 @@ package body Checks is and then Etype (N) = Entity (N) then Rewrite (N, - New_Occurrence_Of (First_Formal (Current_Subprogram), Loc)); + New_Occurrence_Of (First_Formal (Enclosing_Init_Proc), Loc)); end if; return OK; @@ -4187,7 +4187,7 @@ package body Checks is -- Replace references to the current instance of the type with the -- corresponding _init formal of the initialization procedure. - if Within_Init_Proc then + if Inside_Init_Proc then Search_And_Replace_Current_Instance (Dval); end if; diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 8be767adb024..4cfe61b6dccd 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2950,7 +2950,7 @@ package body Exp_Aggr is Build_Initialization_Call (N, Id_Ref => Ref, Typ => Init_Typ, - In_Init_Proc => Within_Init_Proc, + In_Init_Proc => Inside_Init_Proc, With_Default_Init => Has_Default_Init_Comps (N) or else Has_Task (Base_Type (Init_Typ)))); @@ -2985,7 +2985,7 @@ package body Exp_Aggr is Build_Initialization_Call (N, Id_Ref => Ref, Typ => Init_Typ, - In_Init_Proc => Within_Init_Proc, + In_Init_Proc => Inside_Init_Proc, With_Default_Init => Has_Default_Init_Comps (N), Constructor_Ref => Ancestor)); diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb index 1a8d10f9d8aa..fda229c2e8df 100644 --- a/gcc/ada/exp_ch2.adb +++ b/gcc/ada/exp_ch2.adb @@ -322,7 +322,7 @@ package body Exp_Ch2 is -- because the pragma is analyzed in the task declaration -- but is expanded in the call to Create_Task in the init_proc. - elsif Within_Init_Proc then + elsif Inside_Init_Proc then Set_Entity (N, Discriminal (CR_Discriminant (Entity (N)))); else Set_Entity (N, Discriminal (Entity (N))); diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index c46cd8cd2ef1..17e79702a23a 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -4627,7 +4627,7 @@ package body Exp_Ch7 is -- to the component. Signal the nearest suitable scope that it -- is safe to manage the secondary stack. - if Manage_Sec_Stack and then Within_Init_Proc then + if Manage_Sec_Stack and then Inside_Init_Proc then Delegate_Sec_Stack_Management; end if; diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index 44d1e007a955..88e74b566c31 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -1169,13 +1169,11 @@ package body Exp_Pakd is -- out-of-range value by design. Compile this value without checks, -- because a call to the array init_proc must not raise an exception. - -- Condition is not consistent with description above, Within_Init_Proc + -- Condition is not consistent with description above, Inside_Init_Proc -- is True also when we are building the IP for a record or protected -- type that has a packed array component??? - if Within_Init_Proc - and then Initialize_Scalars - then + if Inside_Init_Proc and then Initialize_Scalars then Analyze_And_Resolve (Rhs, Ctyp, Suppress => All_Checks); else Analyze_And_Resolve (Rhs, Ctyp); diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 24828e4a250e..89ffe62d5c50 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6090,7 +6090,7 @@ package body Exp_Util is -- generate the proper actual subtype for it. if Nkind (Exp) = N_Selected_Component - and then Within_Init_Proc + and then Inside_Init_Proc then declare Decl : constant Node_Id := diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 44fa07dfd8a7..9dafd710799e 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6384,7 +6384,7 @@ package body Sem_Ch3 is and then not (Is_Internal (Id) and then Is_TSS (Scope (Id), TSS_Composite_Equality)) - and then not Within_Init_Proc + and then not Inside_Init_Proc and then not All_Composite_Constraints_Static (Cstr) then Check_Restriction (No_Dynamic_Sized_Objects, Cstr); @@ -11155,7 +11155,7 @@ package body Sem_Ch3 is Mutate_Ekind (Def_Id, Ekind (T)); end if; - if For_Access and then Within_Init_Proc then + if For_Access and then Inside_Init_Proc then null; else Append_Elmt (Def_Id, Private_Dependents (T)); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 8080125dda9b..b33119879f15 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -26259,7 +26259,7 @@ package body Sem_Util is if not Report then return False; - elsif not Within_Init_Proc then + elsif not Inside_Init_Proc then return True; elsif Is_Init_Proc (Entity (Name (N))) then @@ -30931,26 +30931,6 @@ package body Sem_Util is end if; end Warn_On_Hiding_Entity; - ---------------------- - -- Within_Init_Proc -- - ---------------------- - - function Within_Init_Proc return Boolean is - S : Entity_Id; - - begin - S := Current_Scope; - while not Is_Overloadable (S) loop - if S = Standard_Standard then - return False; - else - S := Scope (S); - end if; - end loop; - - return Is_Init_Proc (S); - end Within_Init_Proc; - --------------------------- -- Within_Protected_Type -- --------------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index bf76dc96fbf2..4cce1832614c 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -3614,9 +3614,6 @@ package Sem_Util is -- generate the list of visible ancestors; otherwise their partial -- view is added to the resulting list. - function Within_Init_Proc return Boolean; - -- Determines if Current_Scope is within an init proc - function Within_Protected_Type (E : Entity_Id) return Boolean; -- Returns True if entity E is declared within a protected type
