OSDN Git Service

PR c++/50220
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Aug 2011 15:29:04 +0000 (15:29 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Aug 2011 15:29:04 +0000 (15:29 +0000)
* semantics.c (add_capture): Call complete_type for copy.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@178328 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 8d11b49..0f4674e 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50220
+       * semantics.c (add_capture): Call complete_type for copy.
+
        PR c++/50234
        * semantics.c (cxx_eval_component_reference): Handle
        value-initialization for omitted initializers.
index 5434c42..5c8b37d 100644 (file)
@@ -8292,6 +8292,9 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p,
       if (!real_lvalue_p (initializer))
        error ("cannot capture %qE by reference", initializer);
     }
+  else
+    /* Capture by copy requires a complete type.  */
+    type = complete_type (type);
 
   /* Make member variable.  */
   member = build_lang_decl (FIELD_DECL, id, type);
index 9920ea3..8e1db5d 100644 (file)
@@ -1,5 +1,8 @@
 2011-08-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50220
+       * g++.dg/cpp0x/lambda/lambda-50220.C: New.
+
        PR c++/50234
        * g++.dg/cpp0x/constexpr-value3.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C
new file mode 100644 (file)
index 0000000..240143c
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/50220
+// { dg-options -std=c++0x }
+
+template<typename Foo> struct Foobar {};
+
+void foobar(const Foobar<void>& obj)
+{
+  [obj](){}();
+}