From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74812 invoked by alias); 26 Oct 2015 10:46:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 74797 invoked by uid 89); 26 Oct 2015 10:46:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 26 Oct 2015 10:46:33 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 93F552975A; Mon, 26 Oct 2015 06:46:31 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id S75CIoOYD0BO; Mon, 26 Oct 2015 06:46:31 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 841DC286E4; Mon, 26 Oct 2015 06:46:31 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 805C218F; Mon, 26 Oct 2015 06:46:31 -0400 (EDT) Date: Mon, 26 Oct 2015 10:46:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Spurious duplicate Default_Iterator error Message-ID: <20151026104631.GA48287@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-10/txt/msg02688.txt.bz2 --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 650 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 * sem_ch13.adb (Check_Iterator_Functions): For a Default_Iterator aspect, make sure an implicitly declared interpretation is overridden by an explicit one. --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 1701 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; --ReaqsoxgOBHFXBhH--