From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28181 invoked by alias); 6 Dec 2017 22:37:27 -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 28171 invoked by uid 89); 6 Dec 2017 22:37:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Hx-languages-length:1901, friend X-HELO: mail-it0-f52.google.com Received: from mail-it0-f52.google.com (HELO mail-it0-f52.google.com) (209.85.214.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Dec 2017 22:37:25 +0000 Received: by mail-it0-f52.google.com with SMTP id r6so10034260itr.3 for ; Wed, 06 Dec 2017 14:37:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/JJpbil5LCPFX4xCp6jn/VMghsJTDO2qMfJ1uTJfbqI=; b=J2Jbb24PmEhE0c3TS2BzC8WaenFSRqGgq8OxNNyycbq1cg6F+fxuyORRVNse39ria5 06ErvRm0KgnR3tZfKkfozTXblh0SdGcTFpQJT+bcorxUXmLfCB4rWUkKrdgU3FH2NA73 /kLTWwtjFb7Xus8mWlBEl0VSqQ2VjRk6dj6H4/P6h962ChI6Swm9TKInY39RW32dU998 FxHJ5nunh2M6YAV3DhVGubA0vmuQ/Jp4PsCqD43lKbcQloSzAbDG8OzkQvibTpIYZiAm bIYvCRjLXVQRj7H+Lrj8/2hfwHF415Gx6Q6VEWjYDN5h3POvfiN3ul98NczymRa9Lebu GylQ== X-Gm-Message-State: AKGB3mIwNMkiCPV5aIfkf6YnOCTVAbTyC24g2pzmBuNfz1a2PwHMMDGM LSDb9tfFa82FnbpwKAp8h7oHVNI1j7XZ5Hd9oBT94Q== X-Google-Smtp-Source: AGs4zMZMPjG5SkhsYDwdVDx0xCId6ZNhUYm4EeSMY/0MOLRzX4YQZ60NmoUZb4yfRXX8piYlYdqK8brJpf4FLV/yGXY= X-Received: by 10.36.93.5 with SMTP id w5mr4597641ita.124.1512599838625; Wed, 06 Dec 2017 14:37:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.137.195 with HTTP; Wed, 6 Dec 2017 14:36:58 -0800 (PST) In-Reply-To: <20171202001349.GB2353@tucnak> References: <20171202001349.GB2353@tucnak> From: Jason Merrill Date: Wed, 06 Dec 2017 22:37:00 -0000 Message-ID: Subject: Re: [C++ PATCH] Diagnose = delete override of a friend function defined earlier (PR c++/80259) To: Jakub Jelinek Cc: Nathan Sidwell , gcc-patches List Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00350.txt.bz2 OK. On Fri, Dec 1, 2017 at 7:13 PM, Jakub Jelinek wrote: > Hi! > > As the testcase shows, we weren't diagnosing the foo case in the testcase > and would just silently overwrite old DECL_INITIAL with error_mark_node > and ICE later on. Fixed thusly, bootstrapped/regtested on x86_64-linux > and i686-linux, ok for trunk? > > 2017-12-01 Jakub Jelinek > > PR c++/80259 > * decl2.c (grokfield): Diagnose = delete redefinition of a friend. > > * g++.dg/cpp0x/pr80259.C: New test. > > --- gcc/cp/decl2.c.jj 2017-11-21 08:43:50.000000000 +0100 > +++ gcc/cp/decl2.c 2017-12-01 12:01:32.671514761 +0100 > @@ -911,9 +911,18 @@ grokfield (const cp_declarator *declarat > { > if (init == ridpointers[(int)RID_DELETE]) > { > - DECL_DELETED_FN (value) = 1; > - DECL_DECLARED_INLINE_P (value) = 1; > - DECL_INITIAL (value) = error_mark_node; > + if (friendp && decl_defined_p (value)) > + { > + error ("redefinition of %q#D", value); > + inform (DECL_SOURCE_LOCATION (value), > + "%q#D previously defined here", value); > + } > + else > + { > + DECL_DELETED_FN (value) = 1; > + DECL_DECLARED_INLINE_P (value) = 1; > + DECL_INITIAL (value) = error_mark_node; > + } > } > else if (init == ridpointers[(int)RID_DEFAULT]) > { > --- gcc/testsuite/g++.dg/cpp0x/pr80259.C.jj 2017-12-01 12:06:54.611405404 +0100 > +++ gcc/testsuite/g++.dg/cpp0x/pr80259.C 2017-12-01 12:06:19.000000000 +0100 > @@ -0,0 +1,13 @@ > +// PR c++/80259 > +// { dg-do compile { target c++11 } } > + > +void foo () {} // { dg-message "previously defined here" } > +void bar (); > + > +struct A > +{ > + friend void foo () = delete; // { dg-error "redefinition of" } > + friend void bar () = delete; // { dg-message "previously defined here" } > +}; > + > +void bar () {} // { dg-error "redefinition of" } > > Jakub