From c4f372c54f24fd24f1092fb6a09c31c7733ce8cc Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 19 Sep 2019 08:13:25 +0000 Subject: [PATCH] [Ada] Remove duplicated routines for getting homonym number Routines Homonym_Number and Get_Homonym_Number were exactly the same, except for minor style differences. Keep the one in Exp_Util; remove the one in Exp_Dbug. No test attached, because semantics is unaffected. 2019-09-19 Piotr Trojanek gcc/ada/ * exp_dbug.ads, exp_dbug.adb (Get_Homonym_Number): Remove. (Append_Homonym_Number): Use Homonym_Number instead of Get_Homonym_Number. * exp_util.ads, exp_util.adb (Homonym_Number): Mirror style of the removed Get_Homonym_Number routine, i.e. initialize local objects at declaration and refine the type of result. * sem_util.adb (Add_Homonym_Suffix): Use Homonym_Number instead of Get_Homonym_Number. From-SVN: r275940 --- gcc/ada/ChangeLog | 11 +++++++++++ gcc/ada/exp_dbug.adb | 23 ++--------------------- gcc/ada/exp_dbug.ads | 4 ---- gcc/ada/exp_util.adb | 8 +++----- gcc/ada/exp_util.ads | 2 +- gcc/ada/sem_util.adb | 3 +-- 6 files changed, 18 insertions(+), 33 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2caf52d..1f3128e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2019-09-19 Piotr Trojanek + + * exp_dbug.ads, exp_dbug.adb (Get_Homonym_Number): Remove. + (Append_Homonym_Number): Use Homonym_Number instead of + Get_Homonym_Number. + * exp_util.ads, exp_util.adb (Homonym_Number): Mirror style of + the removed Get_Homonym_Number routine, i.e. initialize local + objects at declaration and refine the type of result. + * sem_util.adb (Add_Homonym_Suffix): Use Homonym_Number instead + of Get_Homonym_Number. + 2019-09-19 Ed Schonberg * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Simplify diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb index c2d2318..5f65098 100644 --- a/gcc/ada/exp_dbug.adb +++ b/gcc/ada/exp_dbug.adb @@ -27,6 +27,7 @@ with Alloc; with Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; +with Exp_Util; use Exp_Util; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; @@ -224,7 +225,7 @@ package body Exp_Dbug is Homonym_Numbers (Homonym_Len) := '_'; end if; - Add_Nat_To_H (Get_Homonym_Number (E)); + Add_Nat_To_H (Homonym_Number (E)); end if; end Append_Homonym_Number; @@ -1054,26 +1055,6 @@ package body Exp_Dbug is end loop; end Build_Subprogram_Instance_Renamings; - ------------------------ - -- Get_Homonym_Number -- - ------------------------ - - function Get_Homonym_Number (E : Entity_Id) return Pos is - H : Entity_Id := Homonym (E); - Nr : Pos := 1; - - begin - while Present (H) loop - if Scope (H) = Scope (E) then - Nr := Nr + 1; - end if; - - H := Homonym (H); - end loop; - - return Nr; - end Get_Homonym_Number; - ------------------------------------ -- Get_Secondary_DT_External_Name -- ------------------------------------ diff --git a/gcc/ada/exp_dbug.ads b/gcc/ada/exp_dbug.ads index ac40a40..93b9783 100644 --- a/gcc/ada/exp_dbug.ads +++ b/gcc/ada/exp_dbug.ads @@ -460,10 +460,6 @@ package Exp_Dbug is -- Subprograms for Handling Qualification -- -------------------------------------------- - function Get_Homonym_Number (E : Entity_Id) return Pos; - -- Return the homonym number for E, which is its position in the homonym - -- chain starting at 1. This is exported for use in GNATprove. - procedure Qualify_Entity_Names (N : Node_Id); -- Given a node N, that represents a block, subprogram body, or package -- body or spec, or protected or task type, sets a fully qualified name diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 06f5cc3..905e3f4 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6795,13 +6795,11 @@ package body Exp_Util is -- Homonym_Number -- -------------------- - function Homonym_Number (Subp : Entity_Id) return Nat is - Count : Nat; - Hom : Entity_Id; + function Homonym_Number (Subp : Entity_Id) return Pos is + Hom : Entity_Id := Homonym (Subp); + Count : Pos := 1; begin - Count := 1; - Hom := Homonym (Subp); while Present (Hom) loop if Scope (Hom) = Scope (Subp) then Count := Count + 1; diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index ab33e8d..02fb233 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -734,7 +734,7 @@ package Exp_Util is -- pragmas at the start of the package declaration contains -- pragma Annotate (GNATprove, External_Axiomatization); - function Homonym_Number (Subp : Entity_Id) return Nat; + function Homonym_Number (Subp : Entity_Id) return Pos; -- Here subp is the entity for a subprogram. This routine returns the -- homonym number used to disambiguate overloaded subprograms in the same -- scope (the number is used as part of constructed names to make sure that diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 1bcda5f..b276fd2 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -33,7 +33,6 @@ with Elists; use Elists; with Errout; use Errout; with Erroutc; use Erroutc; with Exp_Ch11; use Exp_Ch11; -with Exp_Dbug; use Exp_Dbug; with Exp_Util; use Exp_Util; with Fname; use Fname; with Freeze; use Freeze; @@ -26314,7 +26313,7 @@ package body Sem_Util is if Has_Homonym (U) then declare - N : constant Pos := Get_Homonym_Number (U); + N : constant Pos := Homonym_Number (U); S : constant String := N'Img; begin if N > 1 then -- 2.7.4