From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1744 invoked by alias); 11 Apr 2011 21:49:35 -0000 Received: (qmail 1736 invoked by uid 22791); 11 Apr 2011 21:49:35 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,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, 11 Apr 2011 21:49:30 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3BLnTw3020954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Apr 2011 17:49:29 -0400 Received: from [127.0.0.1] ([10.3.113.3]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3BLnTkg021820 for ; Mon, 11 Apr 2011 17:49:29 -0400 Message-ID: <4DA37763.50008@redhat.com> Date: Mon, 11 Apr 2011 21:49:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48523 (lamda, 'this', templates) Content-Type: multipart/mixed; boundary="------------060405090600030301060302" 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 X-SW-Source: 2011-04/txt/msg00815.txt.bz2 This is a multi-part message in MIME format. --------------060405090600030301060302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 224 Our rewriting for use of 'this' in a lambda used cp_build_indirect_ref, which assumes that we aren't in a template. Using build_x_indirect_ref instead works better. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6. --------------060405090600030301060302 Content-Type: text/plain; name="48523.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="48523.patch" Content-length: 1165 commit 9b7a53bda8938ff42074b1f38a3e0b68cb37e52e Author: Jason Merrill Date: Sat Apr 9 01:40:20 2011 -0400 PR c++/48523 * tree.c (maybe_dummy_object): Use build_x_indirect_ref rather than cp_build_indirect_ref. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d6b6197..ad004bb 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2423,7 +2423,7 @@ maybe_dummy_object (tree type, tree* binfop) else if (current != current_class_type && context == nonlambda_method_basetype ()) /* In a lambda, need to go through 'this' capture. */ - decl = (cp_build_indirect_ref + decl = (build_x_indirect_ref ((lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (current_class_type))), RO_NULL, tf_warning_or_error)); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C new file mode 100644 index 0000000..29cd2a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C @@ -0,0 +1,13 @@ +// PR c++/48523 +// { dg-options -std=c++0x } + +template +struct X +{ + bool b; + + void f() + { + [this]{ return b; }; + } +}; --------------060405090600030301060302--