Compiler rejects an instantiation involving a formal package that
contains adjacent subprogram declarations with the same name, because in
the matching between entities in the formal package and the
corresponding actual package, it maps two successive entities in the
formal with the same entity (with a different signature) in the actual.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch12.adb (Instantiate_Formal_Package): If previous matched
entity is overloadable, advance in the list of actuals of the
actual package, to prevent an erroneous match of two adjacent
overloadable homonyms with the same entity.
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -10801,6 +10801,16 @@ package body Sem_Ch12 is
Next_Non_Pragma (Formal_Node);
Next (Actual_Of_Formal);
+ -- A formal subprogram may be overloaded, so advance in
+ -- the list of actuals to make sure we do not match two
+ -- successive formals to the same actual. This is only
+ -- relevant for overloadable entities, others have
+ -- distinct names.
+
+ if Is_Overloadable (Actual_Ent) then
+ Next_Entity (Actual_Ent);
+ end if;
+
else
-- No further formals to match, but the generic part may
-- contain inherited operation that are not hidden in the