This patch fixes a bug that caused the compiler to issue the error "default iterator must be unique" when one of the alleged "duplicates" is overridden by another. This can happen in cases involving types derived from types declared in generic formal packages. The error message (when it is correct) is also improved to mention where the duplicate declarations occur. No small test is available.
Tested on x86_64-pc-linux-gnu, committed on trunk 2015-10-26 Bob Duff <d...@adacore.com> * sem_ch13.adb (Check_Iterator_Functions): For a Default_Iterator aspect, make sure an implicitly declared interpretation is overridden by an explicit one.
Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 229320) +++ sem_ch13.adb (working copy) @@ -4277,8 +4277,8 @@ else declare Default : Entity_Id := Empty; - I : Interp_Index; - It : Interp; + I : Interp_Index; + It : Interp; begin Get_First_Interp (Expr, I, It); @@ -4289,12 +4289,21 @@ Remove_Interp (I); elsif Present (Default) then - Error_Msg_N ("default iterator must be unique", Expr); - Error_Msg_Sloc := Sloc (Default); - Error_Msg_N ("\\possible interpretation#", Expr); - Error_Msg_Sloc := Sloc (It.Nam); - Error_Msg_N ("\\possible interpretation#", Expr); + -- An explicit one should override an implicit one + + if Comes_From_Source (Default) = + Comes_From_Source (It.Nam) + then + Error_Msg_N ("default iterator must be unique", Expr); + Error_Msg_Sloc := Sloc (Default); + Error_Msg_N ("\\possible interpretation#", Expr); + Error_Msg_Sloc := Sloc (It.Nam); + Error_Msg_N ("\\possible interpretation#", Expr); + + elsif Comes_From_Source (It.Nam) then + Default := It.Nam; + end if; else Default := It.Nam; end if;