PR c++/65843
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 2015 18:15:24 +0000 (18:15 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Jun 2015 18:15:24 +0000 (18:15 +0000)
* pt.c (tsubst_copy_and_build): Register a capture proxy in
local_specializations.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224676 138bc75d-0d04-0410-961f-82ee72b054a4

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

index eb8d97a..4f2d4a6 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-19  Jason Merrill  <jason@redhat.com>
+
+       PR c++/65843
+       * pt.c (tsubst_copy_and_build): Register a capture proxy in
+       local_specializations.
+
 2015-06-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/66001
index ccce90d..5dd5bfe 100644 (file)
@@ -15665,7 +15665,11 @@ tsubst_copy_and_build (tree t,
              r = build_cxx_call (wrap, 0, NULL, tf_warning_or_error);
          }
        else if (outer_automatic_var_p (r))
-         r = process_outer_var_ref (r, complain);
+         {
+           r = process_outer_var_ref (r, complain);
+           if (is_capture_proxy (r))
+             register_local_specialization (r, t);
+         }
 
        if (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE)
          /* If the original type was a reference, we'll be wrapped in
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-rep1.C
new file mode 100644 (file)
index 0000000..a35060b
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/65843
+// { dg-do compile { target c++11 } }
+
+template<class T>
+void test(T b)
+{
+    const int a = b;
+    [&] () { return a, a; }();
+}
+
+int main() {
+    test(1);
+ return 0;
+}