From patchwork Mon May 30 20:19:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 627951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rJSfZ1JdJz9t50 for ; Tue, 31 May 2016 06:20:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=BzMihUXk; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=J2RySZpX1TO1+sb6B//bzTgHbv6GKAnLGWV2PvZWDV2WhHB5HG6qZ eYtnuneb5C5+hjU+RwDFCUTPdawMK8IOJVCI/CVn86jdHoWCEWGumgxlDhkV7sCm IsafWg3cWtQqyw5Zs5TEq/lCvuUFelu0zztGsy39wLzkDwGgXh4jvQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=1NSdrF5aQJOR1LZFY74VsnOCmLM=; b=BzMihUXkGWioNQdNDBj2 AhVk0Nk5JwG4fTjfGJ7RKEYwlArASpmd9sSbRxNVxsnNubV4qWPumlsJE5jigq/x 4vogQX/sxd0m//5e6ayxj6rwQ8zE0ZpxIuWZ7lozMeesjoAD4Kg7k0J21ckyhiBc w7e8TQlbk5JFV9fhW2CrZwA= Received: (qmail 100118 invoked by alias); 30 May 2016 20:20:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 100108 invoked by uid 89); 30 May 2016 20:20:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Hx-languages-length:1838, friend X-HELO: mail-qk0-f195.google.com Received: from mail-qk0-f195.google.com (HELO mail-qk0-f195.google.com) (209.85.220.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 30 May 2016 20:20:01 +0000 Received: by mail-qk0-f195.google.com with SMTP id l68so22178384qkf.3 for ; Mon, 30 May 2016 13:20:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cZzamt7+sBEguNdJD/BCguRakeT6Lrl4CHgEaBXWDeE=; b=ccCoffk4eiwCHlCHHjMG3LOi7XhoMChA5O9HKHt9ylt6A7BjLTBYIgaZXp+mFt4fZg rpdMPn6bdkMZnCyk7x+RKKJfbOMcMYKpDeeLL/6o1rzOXmz65re8a2v0ZTd3r4TDZY9V 7Vd5lG3RwuTMy294jUBTE0TKy17MqMkOJHh5pHBtJ/UJuHdtj/CH1/3B8qtFRZessxVY Z7vM/jquymnZ048rIomEpuvI81y1HZ7zznsqTBxGiAYOFNoTPWEjPIw0bschBnO3pNfF YylG5yvr2nC4eI94vDWH5eqvW5JbRN46E4WKhXsYHu+6rglR1/GbCSFa5mt0PBHfDGqi XZOA== X-Gm-Message-State: ALyK8tKo1n8WJlBo0Zw1RHGyFjQiRckpfL8g2IZefgoquXqt2QfwofBz5YVdZdsyDHFMQA== X-Received: by 10.55.24.212 with SMTP id 81mr23070437qky.146.1464639599796; Mon, 30 May 2016 13:19:59 -0700 (PDT) Received: from localhost.localdomain (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id b6sm10081979qte.1.2016.05.30.13.19.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 13:19:58 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] Fix PR c++/27100 Date: Mon, 30 May 2016 16:19:51 -0400 Message-Id: <20160530201951.17380-1-patrick@parcs.ath.cx> In-Reply-To: <1460851111-24789-1-git-send-email-patrick@parcs.ath.cx> References: <1460851111-24789-1-git-send-email-patrick@parcs.ath.cx> Here's a more straightforward version of the patch that abuses the fact that the fields DECL_PENDING_INLINE_INFO and DECL_SAVED_FUNCTION_DATA are a union. Bootstrapped + regtested on x86_64-pc-linux-gnu. Does this look OK to commit? gcc/cp/ChangeLog: PR c++/27100 * decl.c (duplicate_decls): Copy the DECL_PENDING_INLINE_P flag. gcc/testsuite/ChangeLog: PR c++/27100 * g++.dg/other/friend6.C: New test. --- gcc/cp/decl.c | 11 +++++++++-- gcc/testsuite/g++.dg/other/friend6.C | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/friend6.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 90e147c..b26e8ae 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2351,8 +2351,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else { - if (DECL_PENDING_INLINE_INFO (newdecl) == 0) - DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); + if (DECL_PENDING_INLINE_INFO (newdecl) == NULL) + { + /* This also copies DECL_SAVED_FUNCTION_DATA since the two fields + are a union (tagged by DECL_PENDING_INLINE_P). */ + DECL_PENDING_INLINE_INFO (newdecl) + = DECL_PENDING_INLINE_INFO (olddecl); + DECL_PENDING_INLINE_P (newdecl) + = DECL_PENDING_INLINE_P (olddecl); + } DECL_DECLARED_INLINE_P (newdecl) |= DECL_DECLARED_INLINE_P (olddecl); diff --git a/gcc/testsuite/g++.dg/other/friend6.C b/gcc/testsuite/g++.dg/other/friend6.C new file mode 100644 index 0000000..5f593a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend6.C @@ -0,0 +1,15 @@ +// PR c++/27100 +// This used to fail at link time with an "undefined reference to 'foo'" error. +// { dg-do link } + +struct A +{ + friend void foo (const A&) { } + friend void foo (const A&); +}; + +int +main () +{ + foo (A ()); +}