From patchwork Mon Aug 17 18:39:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 508049 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 360F614012C for ; Tue, 18 Aug 2015 04:39:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=A5Hd0bR8; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=oMC2r0tO9Idj/bwJwbMOLZIIYthL2KpZNmqYsiCMmE1nW51ZU0 5TfM7RIB6dVIxIbha1y1NjPbG6MjONdnRgqmn5k9ExWavnpB5Zxz7gL9ogjNBy7H +fkGkpAgY4O1Gffu/NPGJSBqjRw95/lkm+sThCRjWYdqaMqWeFTNWe4ys= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=Cl90TG2Jjt0+Sk1wwJxfEh0a3RE=; b=A5Hd0bR8WqaiwSfLLfWX yoBA5q5ctXt6H6HYg7r023/Ta0J82r4Uh33rGHo3rCbcsp4pLfbBldJnD9CJu+g9 engv58sCOeEcCVgciUccaj9yqV/qp2eoQ/G7L9WR6ow/H0KrZwCKHFd/uxmwXU/M uGLgHA06MQzV8vADoHWXqmQ= Received: (qmail 64040 invoked by alias); 17 Aug 2015 18:39:11 -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 64031 invoked by uid 89); 17 Aug 2015 18:39:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 17 Aug 2015 18:39:10 +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 (Postfix) with ESMTPS id 8C25B8E507 for ; Mon, 17 Aug 2015 18:39:09 +0000 (UTC) Received: from [10.10.116.45] ([10.10.116.45]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7HId8e3020856 for ; Mon, 17 Aug 2015 14:39:09 -0400 To: gcc-patches List From: Jason Merrill Subject: C++ PATCH for c++/67244 (ICE with nested lambda) Message-ID: <55D22A4A.4080109@redhat.com> Date: Mon, 17 Aug 2015 14:39:06 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 We were forgetting to register capture proxies for new captures during template instantiation. Tested x86_64-pc-linux-gnu, applying to trunk and 5. commit 6dbfe4dd24e6f001f17e8ea4cf1aa58f4b22ebc8 Author: Jason Merrill Date: Mon Aug 17 13:59:52 2015 -0400 PR c++/67244 * pt.c (tsubst_copy_and_build): Call insert_pending_capture_proxies. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ecd86e4..b84bda4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16344,6 +16344,8 @@ tsubst_copy_and_build (tree t, LAMBDA_EXPR_THIS_CAPTURE (r) = NULL_TREE; + insert_pending_capture_proxies (); + RETURN (build_lambda_object (r)); } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested5.C new file mode 100644 index 0000000..3ebdf3b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested5.C @@ -0,0 +1,29 @@ +// PR c++/67244 +// { dg-do compile { target c++11 } } + +class A { +public: + int operator*(); +}; +template +void searchGen(int, int, T, Predicate p4) { + p4(0); +} +template struct B; +template +struct B { + static void exec() { MetaFunction::template exec; } +}; +template void forEachType() { + B::exec; +} +namespace { +struct C { + template void exec() { + A __trans_tmp_1; + const auto target = *__trans_tmp_1; + searchGen(0, 0, 0, [=](T) { [=] { target; }; }); + } +}; +} +void ____C_A_T_C_H____T_E_S_T____75() { forEachType; }