From patchwork Mon Jul 2 19:09:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 168632 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]) by ozlabs.org (Postfix) with SMTP id DE1032C009F for ; Tue, 3 Jul 2012 05:09:33 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1341860974; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=FZq8k5A 9mP5ZBRAqvQq1IWfvgYo=; b=LYFAjPtO8chJlsaqWOS/qAWlr6cG6jd8vVnAlkQ YIOGGKD8esinjQglp+hqRDhWqnYAwBAyH0En68HydoN/ctM5zoBetg4LGLcWVyEG VM15BImN+sPGkDzn3stOUfUCfiLFqU2ht3MXpgYRv8A028qh7kCQ+fc1/sVlC24R mvXg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=AJWJ+kLuyZE4ObIPClbgnTSuzk6MFbjl4xEW2PXXCVcIj273SJu4D3BCoEwvy1 PSR92fpWuvmNxSm3ssHcjf6kuFY50ZXGG5mQkZFca0An9bN21hmwqH3gR6sSjg4+ iVCgl/W2ez/RAB7s/0DgVobH0UJabYXhkfVvnSqnIA/+o=; Received: (qmail 10891 invoked by alias); 2 Jul 2012 19:09:27 -0000 Received: (qmail 10875 invoked by uid 22791); 2 Jul 2012 19:09:26 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Jul 2012 19:09:12 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q62J9DRs002072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Jul 2012 15:09:13 -0400 Received: from [10.3.113.9] ([10.3.113.9]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q62J9CZn012233 for ; Mon, 2 Jul 2012 15:09:13 -0400 Message-ID: <4FF1F1D7.50100@redhat.com> Date: Mon, 02 Jul 2012 15:09:11 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/53821 (multiply defined lambda member functions) 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 It seems that since my change to avoid push_to_top_level for instantiating lambdas, the code in maybe_add_lambda_conv_op for handling function context activates and does the wrong thing. I don't remember why I added the code that sets DECL_INTERFACE_KNOWN, but it doesn't seem to be needed. This patch restores the old behavior for the testcase. While looking at it I notice that the op() itself is incorrectly emitted as a local function rather than COMDAT, but that will wait for another patch. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit 45299163c2e02cde76e8b5bb8c2ecf11bda0b616 Author: Jason Merrill Date: Mon Jul 2 13:53:05 2012 -0400 PR c++/53821 * semantics.c (maybe_add_lambda_conv_op): Don't set DECL_INTERFACE_KNOWN. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f1a94c1..8e37ebb 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9336,8 +9336,6 @@ maybe_add_lambda_conv_op (tree type) DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; DECL_ARGUMENTS (fn) = build_this_parm (fntype, TYPE_QUAL_CONST); - if (nested) - DECL_INTERFACE_KNOWN (fn) = 1; add_method (type, fn, NULL_TREE); @@ -9368,8 +9366,6 @@ maybe_add_lambda_conv_op (tree type) DECL_ARGUMENTS (fn) = copy_list (DECL_CHAIN (DECL_ARGUMENTS (callop))); for (arg = DECL_ARGUMENTS (fn); arg; arg = DECL_CHAIN (arg)) DECL_CONTEXT (arg) = fn; - if (nested) - DECL_INTERFACE_KNOWN (fn) = 1; add_method (type, fn, NULL_TREE); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C new file mode 100644 index 0000000..5e85619 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template6.C @@ -0,0 +1,14 @@ +// PR c++/53821 +// { dg-final { scan-assembler-not "_ZZ1fIvEvvENKUlvE_cvPFvvEEv" } } +// { dg-do compile { target c++11 } } + +template void f() +{ + auto g = []{}; + g(); +} + +int main() +{ + f(); +}