From patchwork Mon Sep 10 23:44:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 182975 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 3D1052C0080 for ; Tue, 11 Sep 2012 09:45:17 +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=1347925518; 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=B4mskD7 CRuzjh/O7e8QMqGAx3KU=; b=HkAjhgyuBy97qCSxaM3Ziq6Vc6KL7zOwN4O/Hxp DBAY4SsSOq9MdcgAJKmTO+MHt5T/nTCIkcoN/iQR+Rtc6r/Ood6jnFW6oKkH5Mw2 3q6mWwiOWE5LhQAHrMp81hMJf3BHlOP+jGTN/gMzMDSCR4fXL9Wknx2J4TRVUSkN yNAI= 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=FWcUefPkxasqN+GFxt3s1lunGdp6YtPl8PV+yBZx2FigVIuvuyQLAlXJei/9Oe 6RqlX79oR/zg7S8H6EMNlCZ9lmIoXAxsWq+z/VhVleMQXkhMyxFyUwR5deLgfVWf g2H3YuLM3dG3W0Wxj0Gg5XF1zf4IygCPLnlx2AxYtwKCs=; Received: (qmail 18642 invoked by alias); 10 Sep 2012 23:45:11 -0000 Received: (qmail 18619 invoked by uid 22791); 10 Sep 2012 23:45:10 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 10 Sep 2012 23:44:54 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8ANisDZ024664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 10 Sep 2012 19:44:54 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8ANirnv014591 for ; Mon, 10 Sep 2012 19:44:53 -0400 Message-ID: <504E7B75.301@redhat.com> Date: Mon, 10 Sep 2012 19:44:53 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/54538 (lambda mangling) 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 This bug was introduced by the fix for 53783; the change from tsubst_copy to tsubst messed up handling of FIELD_DECLs, because tsubst of a FIELD_DECL always creates a new one. Fixed by limiting the 53783 change to FUNCTION_DECLs. Tested x86_64-pc-linux-gnu, applying to trunk. commit d61bd5ca5d9e57ed3bb2b82cacbcbc110f874349 Author: Jason Merrill Date: Mon Sep 10 15:26:44 2012 -0400 PR c++/54538 PR c++/53783 * pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Go back to using RECUR for LAMBDA_EXPR_EXTRA_SCOPE except for function scope. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cde83f2..a875528 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14199,8 +14199,18 @@ tsubst_copy_and_build (tree t, LAMBDA_EXPR_MUTABLE_P (r) = LAMBDA_EXPR_MUTABLE_P (t); LAMBDA_EXPR_DISCRIMINATOR (r) = (LAMBDA_EXPR_DISCRIMINATOR (t)); - LAMBDA_EXPR_EXTRA_SCOPE (r) - = tsubst (LAMBDA_EXPR_EXTRA_SCOPE (t), args, complain, in_decl); + /* For a function scope, we want to use tsubst so that we don't + complain about referring to an auto function before its return + type has been deduced. Otherwise, we want to use tsubst_copy so + that we look up the existing field/parameter/variable rather + than build a new one. */ + tree scope = LAMBDA_EXPR_EXTRA_SCOPE (t); + if (scope && TREE_CODE (scope) == FUNCTION_DECL) + scope = tsubst (LAMBDA_EXPR_EXTRA_SCOPE (t), args, + complain, in_decl); + else + scope = RECUR (scope); + LAMBDA_EXPR_EXTRA_SCOPE (r) = scope; LAMBDA_EXPR_RETURN_TYPE (r) = tsubst (LAMBDA_EXPR_RETURN_TYPE (t), args, complain, in_decl); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C new file mode 100644 index 0000000..0d37637 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle4.C @@ -0,0 +1,13 @@ +// PR c++/54538 +// { dg-do compile { target c++11 } } + +template +struct A +{ + // { dg-final { scan-assembler "_ZNK1AIcE1pMUlvE_cvPFvvEEv" } } + // { dg-final { scan-assembler "_ZNK1AIiE1pMUlvE_cvPFvvEEv" } } + void (*p)() = []{}; +}; + +A a1; +A a2;