From patchwork Tue Jul 9 17:46:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 257850 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 673E82C02BA for ; Wed, 10 Jul 2013 03:46:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=nkqTPxQuOVidz1GQL9QQ5bcCkpPtNn/F83uKKbrRK+L53I YGeHsUI8JYf8cw6y7/0Ip/y14P9pVVewH74rKXN6MARXmal9l2uyc9FgDmK2zswa 42EvgV+A4lL6ev/qDkhlLcYQxF0yEFzomw0hetHMaQiIOqnpvXFeq8YvjRJ/A= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=YQDDY1yreaXRZzAEh74bCPZQXkg=; b=wE31gH+T8MqgfLtLZAL/ i7JIg8Dt1YSy+0CqPwp6zIT9wzYkvKBI0/Xo93ki8SpV5i8T7l9gm3qJJ7kgg15P Wv/b4E+GiEib7iqWjKW8QejWf5/hglLvbh/XM/DSZsuO4LVIkP7706AXejLnZi0p 4Ikup/6jp9q4pkZu38hk73o= Received: (qmail 15451 invoked by alias); 9 Jul 2013 17:46:52 -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 15442 invoked by uid 89); 9 Jul 2013 17:46:52 -0000 X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS, TW_CX autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 09 Jul 2013 17:46:51 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r69HkoYc013502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Jul 2013 13:46:50 -0400 Received: from [10.3.113.19] ([10.3.113.19]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r69HkgZh011946 for ; Tue, 9 Jul 2013 13:46:47 -0400 Message-ID: <51DC4C80.7040409@redhat.com> Date: Tue, 09 Jul 2013 13:46:40 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0a2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/57526 (ICE with capture of auto* variable) X-Virus-Found: No An earlier patch of mine changed lambda_capture_field_type to avoid building a DECLTYPE_TYPE in cases where it isn't really necessary, but it is necessary in the case of capture of an auto variable. Tested x86_64-pc-linux-gnu, applying to trunk and 4.8. commit 80bb7027cca5a7c0db92fb0338ae55cb44e9b3d6 Author: Jason Merrill Date: Tue Jul 9 02:59:52 2013 -0400 PR c++/57526 * semantics.c (lambda_capture_field_type): Build a DECLTYPE_TYPE if the variable type uses 'auto'. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 57700f7..3699ea5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9078,7 +9078,8 @@ lambda_capture_field_type (tree expr) { tree type; if (type_dependent_expression_p (expr) - && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)) + && !(TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE + && !type_uses_auto (TREE_TYPE (expr)))) { type = cxx_make_type (DECLTYPE_TYPE); DECLTYPE_TYPE_EXPR (type) = expr; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto3.C new file mode 100644 index 0000000..013ed52 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto3.C @@ -0,0 +1,24 @@ +// PR c++/57526 +// { dg-require-effective-target c++11 } + +template +struct A +{ + void bar( ) { } + + void foo( ) + { + auto* this_ptr = this; + auto lc = [&]( ) + { + this_ptr->bar(); + }; + lc(); + } +}; + +int main() +{ + A a; + a.foo(); +}