From: Jason Merrill Date: Wed, 6 Sep 2017 19:36:48 +0000 (-0400) Subject: PR c++/82070 - error with nested lambda capture X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7ab50e17943ee4caaf2fba2d4238a00e0409f1e7;p=gcc.git PR c++/82070 - error with nested lambda capture * pt.c (tsubst_expr) [DECL_EXPR]: Register capture proxies with register_local_specialization. From-SVN: r251819 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c1546308f7c..e497094c4d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-09-06 Jason Merrill + + PR c++/82070 - error with nested lambda capture + * pt.c (tsubst_expr) [DECL_EXPR]: Register capture proxies with + register_local_specialization. + 2017-09-06 Nathan Sidwell * name-lookup.h (lookup_field_1): Delete. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eb27f6a0402..4a65e31b661 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 00000000000..74033150f51 --- /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, [] {}); +}