From patchwork Wed Sep 6 18:56:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 810771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461640-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WgY2Eqc1"; dkim-atps=neutral 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 3xnXrs0x26z9sRV for ; Thu, 7 Sep 2017 04:57:30 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=Ga6RHYZi6wjCQzr/12vIuiQqeUfBN3+ftFslq0q+SUN2yi Wd4E8pITEILacFlnxUuDr233ZOeThox2/RR8eu+SnlINInobIwMFRBJjp+w4L0v9 GLypehQoEq6D68qpwYt0Gj9pIb+PSYVX+vMLN4LVKQJLTHE/6ETPI7NddjG94= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=LpbXLW021I49aUAhd7RoVP46NOc=; b=WgY2Eqc1JOEsXhv9FgWJ y7Qyc1dtH8Lt2MXaWnYB+eoh4UDE5PVRG0JX2Nle/ckdVqBhMm40uTjNr9UkeR09 5pClcpx/Hcu07E/GdsK8lQdaC6HZ2PPYBy/IWGoUPk77YnrbC+/RE0u5ykoZ5AcD suzElgT3ch80WQBtKItI4bw= Received: (qmail 65013 invoked by alias); 6 Sep 2017 18:57:21 -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 63962 invoked by uid 89); 6 Sep 2017 18:57:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=proxies X-HELO: mail-io0-f170.google.com Received: from mail-io0-f170.google.com (HELO mail-io0-f170.google.com) (209.85.223.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Sep 2017 18:57:19 +0000 Received: by mail-io0-f170.google.com with SMTP id d16so278722ioj.3 for ; Wed, 06 Sep 2017 11:57:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=WqQlJMoSCQ71V3/etksFuA1aJNFDZ1JI45dsFAbc/s0=; b=RuOjAp1UTfJhNE1SLwwZawXuG9kFmEIEn65yttHkQfHGelSb32awTVEwCYMpFi9/f9 zDqCsoMhwCsuWspTtPl3na8DHsXLKnVq1bvVW0FJdFQbEjey09w6hcTRA1Q6WeWzIUBG zHEYkbh/od2JNUg85tfEsnKhdoWE4kePLMjSkCOiwyqZjesvEvlDaYMZ3g9yE38lhK0d eFDfI0OPWfcdmTSYeX4HLT8DYre4ofn91OxBrEpWLqp/5W/rWby3S1l5mqNI4BY++/1c kFwtsV3iG49pOodMTHvADjonpbcDxj/L6GDca/cPGVM2khzGIkZMFYozgy9crxrxkYIN GCMA== X-Gm-Message-State: AHPjjUjhZF+fqacU/vPV7JyseOaFN4erEDhY5setNVU2Trlq1vxzU4N+ AYXvqyRS0l5q/STVIC1eE8MjvF7mDfb1dv4= X-Google-Smtp-Source: AOwi7QBLDluH5lBaOHSv43KQ6XXY/1kkpR3plP2LLpvOD3wz3oGXLAww/n741MLH4WXHztYuOmwTaRrntNbN59bbyOQ= X-Received: by 10.107.69.1 with SMTP id s1mr145790ioa.147.1504724236863; Wed, 06 Sep 2017 11:57:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.181.23 with HTTP; Wed, 6 Sep 2017 11:56:56 -0700 (PDT) From: Jason Merrill Date: Wed, 6 Sep 2017 14:56:56 -0400 Message-ID: Subject: C++ PATCH for c++/82070, error with nested lambda capture To: gcc-patches List X-IsSubscribed: yes I was expecting that references to capture proxies would be resolved in the reconstructed lambda by normal name lookup, but that doesn't work in decltype, and processing the nested lambda really wants to find the new capture proxy, not the captured variable. Tested x86_64-pc-linux-gnu, applying to trunk. commit f9a1fe6d129418e72c68d0d1d9d35089ba7817b2 Author: Jason Merrill Date: Wed Sep 6 13:41:58 2017 -0400 PR c++/82070 - error with nested lambda capture * pt.c (tsubst_expr) [DECL_EXPR]: Register capture proxies with register_local_specialization. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eb27f6a..4a65e31 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15985,8 +15985,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, else if (is_capture_proxy (decl) && !DECL_TEMPLATE_INSTANTIATION (current_function_decl)) { - /* We're in tsubst_lambda_expr, we've already inserted new capture - proxies, and uses will find them with lookup_name. */ + /* We're in tsubst_lambda_expr, we've already inserted a new + capture proxy, so look it up and register it. */ + tree inst = lookup_name (DECL_NAME (decl)); + gcc_assert (inst != decl && is_capture_proxy (inst)); + register_local_specialization (inst, decl); break; } else if (DECL_IMPLICIT_TYPEDEF_P (decl) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested7.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested7.C new file mode 100644 index 0000000..7403315 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested7.C @@ -0,0 +1,17 @@ +// PR c++/82070 +// { dg-do compile { target c++11 } } + +namespace a { +template +void +c (int, int, b d) +{ + [d] { [d] {}; }; +} +} +void +e () +{ + int f; + a::c (f, 3, [] {}); +}