PR c++/80267 - ICE with nested capture of reference
authorJason Merrill <jason@redhat.com>
Sun, 9 Apr 2017 05:06:08 +0000 (01:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 9 Apr 2017 05:06:08 +0000 (01:06 -0400)
PR c++/60992
* pt.c (tsubst_copy): Handle lookup finding a capture proxy.

From-SVN: r246793

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested6.C [new file with mode: 0644]

index a31d114374f29aea0b4442c33e6634e22b76eada..e980456918e7d0fab61122c5a78aef8c874aff37 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-07  Jason Merrill  <jason@redhat.com>
+
+       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  <polacek@redhat.com>
 
        PR sanitizer/80348
index f9f4921a11a9959ee6c39511d88472877178e28d..2d1e81fffd1a67cba1787db6d35bae4e96347617 100644 (file)
@@ -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 (file)
index 0000000..58dfe3c
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/80267
+// { dg-do compile { target c++11 } }
+
+template <typename> void a() {
+  int b;
+  auto &c = b;
+  [&] {
+    c;
+    [&] { c; };
+  };
+}
+void d() { a<int>(); }