public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Spurious duplicate Default_Iterator error
@ 2015-10-26 10:46 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-10-26 10:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

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  <duff@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.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1701 bytes --]

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-26 10:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 10:46 [Ada] Spurious duplicate Default_Iterator error Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).