From: Jason Merrill Date: Sun, 9 Apr 2017 05:06:08 +0000 (-0400) Subject: PR c++/80267 - ICE with nested capture of reference X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c60faeee9ecff24636380d2d58b7712cdfb2531f;p=gcc.git PR c++/80267 - ICE with nested capture of reference PR c++/60992 * pt.c (tsubst_copy): Handle lookup finding a capture proxy. From-SVN: r246793 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a31d114374f..e980456918e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-04-07 Jason Merrill + + PR c++/80267 - ICE with nested capture of reference + PR c++/60992 + * pt.c (tsubst_copy): Handle lookup finding a capture proxy. + 2017-04-07 Marek Polacek PR sanitizer/80348 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f9f4921a11a..2d1e81fffd1 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14566,7 +14566,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) { /* First try name lookup to find the instantiation. */ r = lookup_name (DECL_NAME (t)); - if (r) + if (r && !is_capture_proxy (r)) { /* Make sure that the one we found is the one we want. */ tree ctx = DECL_CONTEXT (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested6.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested6.C new file mode 100644 index 00000000000..58dfe3c908f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested6.C @@ -0,0 +1,12 @@ +// PR c++/80267 +// { dg-do compile { target c++11 } } + +template void a() { + int b; + auto &c = b; + [&] { + c; + [&] { c; }; + }; +} +void d() { a(); }