Routine End_Interp_List was part of the API for overloaded resolution
from the very beginning. However, it quickly become unnecessary, because
both adding and removing interpretation maintains a No_Interp marker at
the end of the interpretation list.
The only effect of this routine was that it prevented duplicated
interpretation entries from appearing on the interpretation list, but it
was only because the explicit guard for preventing such duplicates was
not always working.
In particular, this guard didn't work when an overloaded expression of a
generic unit parameter was first preanalyzed (when checking the legality
of the instantiation) and then analyzed (when actually instantiating the
generic unit).
This patch fixes protection against duplicate entries on the lists with
overloaded interpretations and removes the End_Interp_List routine.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch4.adb (Analyze_Call): Remove call to End_Interp_List.
(Process_Overloaded_Indexed_Component): Remove call to
End_Interp_List.
* sem_util.adb (Insert_Explicit_Dereference): Remove call to
End_Interp_List.
* sem_type.ads (End_Interp_List): Remove.
* sem_type.adb (Add_Entry): The guard against duplicate entries
is now checked before other conditions, so that EXIT statements
do not bypass this guard.
(End_Interp_List): Remove.
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -1461,8 +1461,6 @@ package body Sem_Ch4 is
else
Remove_Abstract_Operations (N);
end if;
-
- End_Interp_List;
end if;
-- Check the accessibility level for actuals for explicitly aliased
@@ -2790,8 +2788,6 @@ package body Sem_Ch4 is
Error_Msg_N ("no legal interpretation for indexed component", N);
Set_Is_Overloaded (N, False);
end if;
-
- End_Interp_List;
end Process_Overloaded_Indexed_Component;
-- Start of processing for Analyze_Indexed_Component_Form
diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb
--- a/gcc/ada/sem_type.adb
+++ b/gcc/ada/sem_type.adb
@@ -239,6 +239,13 @@ package body Sem_Type is
Get_First_Interp (N, I, It);
while Present (It.Nam) loop
+ -- Avoid making duplicate entries in overloads
+
+ if Name = It.Nam
+ and then Base_Type (It.Typ) = Base_Type (T)
+ then
+ return;
+
-- A user-defined subprogram hides another declared at an outer
-- level, or one that is use-visible. So return if previous
-- definition hides new one (which is either in an outer
@@ -248,7 +255,7 @@ package body Sem_Type is
-- If this is a universal operation, retain the operator in case
-- preference rule applies.
- if (((Ekind (Name) = E_Function or else Ekind (Name) = E_Procedure)
+ elsif ((Ekind (Name) in E_Function | E_Procedure
and then Ekind (Name) = Ekind (It.Nam))
or else (Ekind (Name) = E_Operator
and then Ekind (It.Nam) = E_Function))
@@ -292,13 +299,6 @@ package body Sem_Type is
return;
end if;
- -- Avoid making duplicate entries in overloads
-
- elsif Name = It.Nam
- and then Base_Type (It.Typ) = Base_Type (T)
- then
- return;
-
-- Otherwise keep going
else
@@ -2227,16 +2227,6 @@ package body Sem_Type is
end if;
end Disambiguate;
- ---------------------
- -- End_Interp_List --
- ---------------------
-
- procedure End_Interp_List is
- begin
- All_Interp.Table (All_Interp.Last) := No_Interp;
- All_Interp.Increment_Last;
- end End_Interp_List;
-
-------------------------
-- Entity_Matches_Spec --
-------------------------
diff --git a/gcc/ada/sem_type.ads b/gcc/ada/sem_type.ads
--- a/gcc/ada/sem_type.ads
+++ b/gcc/ada/sem_type.ads
@@ -130,9 +130,6 @@ package Sem_Type is
-- always Boolean, and we use Opnd_Type, which is a candidate type for one
-- of the operands of N, to check visibility.
- procedure End_Interp_List;
- -- End the list of interpretations of current node
-
procedure Get_First_Interp
(N : Node_Id;
I : out Interp_Index;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -15044,8 +15044,6 @@ package body Sem_Util is
Get_Next_Interp (I, It);
end loop;
- End_Interp_List;
-
else
-- Prefix is unambiguous: mark the original prefix (which might
-- Come_From_Source) as a reference, since the new (relocated) one