diff options
author | Jason Merrill <jason@redhat.com> | 2017-09-06 15:36:48 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-09-06 15:36:48 -0400 |
commit | 7ab50e17943ee4caaf2fba2d4238a00e0409f1e7 (patch) | |
tree | c515a6b0cec58a31cc8aefd30f838e6cd4ebff43 /gcc | |
parent | bbd3510114011baa1be27dde94c55085678c34bf (diff) | |
download | gcc-7ab50e17943ee4caaf2fba2d4238a00e0409f1e7.zip gcc-7ab50e17943ee4caaf2fba2d4238a00e0409f1e7.tar.gz gcc-7ab50e17943ee4caaf2fba2d4238a00e0409f1e7.tar.bz2 |
PR c++/82070 - error with nested lambda capture
* pt.c (tsubst_expr) [DECL_EXPR]: Register capture proxies with
register_local_specialization.
From-SVN: r251819
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested7.C | 17 |
3 files changed, 28 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c154630..e497094 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-09-06 Jason Merrill <jason@redhat.com> + + 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 <nathan@acm.org> * name-lookup.h (lookup_field_1): Delete. 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 <typename b> +void +c (int, int, b d) +{ + [d] { [d] {}; }; +} +} +void +e () +{ + int f; + a::c (f, 3, [] {}); +} |