Commit c4f372c5 by Piotr Trojanek Committed by Pierre-Marie de Rodat

[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  <trojanek@adacore.com>

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
parent 890cde53
2019-09-19 Piotr Trojanek <trojanek@adacore.com>
* 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 <schonberg@adacore.com> 2019-09-19 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Simplify * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Simplify
......
...@@ -27,6 +27,7 @@ with Alloc; ...@@ -27,6 +27,7 @@ with Alloc;
with Atree; use Atree; with Atree; use Atree;
with Debug; use Debug; with Debug; use Debug;
with Einfo; use Einfo; with Einfo; use Einfo;
with Exp_Util; use Exp_Util;
with Nlists; use Nlists; with Nlists; use Nlists;
with Nmake; use Nmake; with Nmake; use Nmake;
with Opt; use Opt; with Opt; use Opt;
...@@ -224,7 +225,7 @@ package body Exp_Dbug is ...@@ -224,7 +225,7 @@ package body Exp_Dbug is
Homonym_Numbers (Homonym_Len) := '_'; Homonym_Numbers (Homonym_Len) := '_';
end if; end if;
Add_Nat_To_H (Get_Homonym_Number (E)); Add_Nat_To_H (Homonym_Number (E));
end if; end if;
end Append_Homonym_Number; end Append_Homonym_Number;
...@@ -1054,26 +1055,6 @@ package body Exp_Dbug is ...@@ -1054,26 +1055,6 @@ package body Exp_Dbug is
end loop; end loop;
end Build_Subprogram_Instance_Renamings; 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 -- -- Get_Secondary_DT_External_Name --
------------------------------------ ------------------------------------
......
...@@ -460,10 +460,6 @@ package Exp_Dbug is ...@@ -460,10 +460,6 @@ package Exp_Dbug is
-- Subprograms for Handling Qualification -- -- 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); procedure Qualify_Entity_Names (N : Node_Id);
-- Given a node N, that represents a block, subprogram body, or package -- 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 -- body or spec, or protected or task type, sets a fully qualified name
......
...@@ -6795,13 +6795,11 @@ package body Exp_Util is ...@@ -6795,13 +6795,11 @@ package body Exp_Util is
-- Homonym_Number -- -- Homonym_Number --
-------------------- --------------------
function Homonym_Number (Subp : Entity_Id) return Nat is function Homonym_Number (Subp : Entity_Id) return Pos is
Count : Nat; Hom : Entity_Id := Homonym (Subp);
Hom : Entity_Id; Count : Pos := 1;
begin begin
Count := 1;
Hom := Homonym (Subp);
while Present (Hom) loop while Present (Hom) loop
if Scope (Hom) = Scope (Subp) then if Scope (Hom) = Scope (Subp) then
Count := Count + 1; Count := Count + 1;
......
...@@ -734,7 +734,7 @@ package Exp_Util is ...@@ -734,7 +734,7 @@ package Exp_Util is
-- pragmas at the start of the package declaration contains -- pragmas at the start of the package declaration contains
-- pragma Annotate (GNATprove, External_Axiomatization); -- 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 -- Here subp is the entity for a subprogram. This routine returns the
-- homonym number used to disambiguate overloaded subprograms in the same -- homonym number used to disambiguate overloaded subprograms in the same
-- scope (the number is used as part of constructed names to make sure that -- scope (the number is used as part of constructed names to make sure that
......
...@@ -33,7 +33,6 @@ with Elists; use Elists; ...@@ -33,7 +33,6 @@ with Elists; use Elists;
with Errout; use Errout; with Errout; use Errout;
with Erroutc; use Erroutc; with Erroutc; use Erroutc;
with Exp_Ch11; use Exp_Ch11; with Exp_Ch11; use Exp_Ch11;
with Exp_Dbug; use Exp_Dbug;
with Exp_Util; use Exp_Util; with Exp_Util; use Exp_Util;
with Fname; use Fname; with Fname; use Fname;
with Freeze; use Freeze; with Freeze; use Freeze;
...@@ -26314,7 +26313,7 @@ package body Sem_Util is ...@@ -26314,7 +26313,7 @@ package body Sem_Util is
if Has_Homonym (U) then if Has_Homonym (U) then
declare declare
N : constant Pos := Get_Homonym_Number (U); N : constant Pos := Homonym_Number (U);
S : constant String := N'Img; S : constant String := N'Img;
begin begin
if N > 1 then if N > 1 then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment