OSDN Git Service

PR c++/43641
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Apr 2010 19:58:49 +0000 (19:58 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Apr 2010 19:58:49 +0000 (19:58 +0000)
* semantics.c (maybe_add_lambda_conv_op): Use build_call_a and tweak
return value directly.

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

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

index 00aa53e..0bb6cbb 100644 (file)
@@ -1,5 +1,9 @@
 2010-04-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43641
+       * semantics.c (maybe_add_lambda_conv_op): Use build_call_a and tweak
+       return value directly.
+
        * call.c (type_decays_to): Call cv_unqualified for non-class type.
 
 2010-04-12  Fabien Chene  <fabien.chene@gmail.com>
index 66d152d..ea01eb3 100644 (file)
@@ -5968,9 +5968,12 @@ maybe_add_lambda_conv_op (tree type)
   VEC_quick_push (tree, argvec, arg);
   for (arg = DECL_ARGUMENTS (statfn); arg; arg = TREE_CHAIN (arg))
     VEC_safe_push (tree, gc, argvec, arg);
-  call = build_cxx_call (callop, VEC_length (tree, argvec),
-                        VEC_address (tree, argvec));
+  call = build_call_a (callop, VEC_length (tree, argvec),
+                      VEC_address (tree, argvec));
   CALL_FROM_THUNK_P (call) = 1;
+  if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call)))
+    call = build_cplus_new (TREE_TYPE (call), call);
+  call = convert_from_reference (call);
   finish_return_stmt (call);
 
   finish_compound_stmt (compound_stmt);
index b73eaa8..03bfcc0 100644 (file)
@@ -1,5 +1,8 @@
 2010-04-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43641
+       * g++.dg/cpp0x/lambda/lambda-conv4.C: New.
+
        * g++.dg/cpp0x/lambda/lambda-deduce2.C: New.
 
 2010-04-12  Fabien Chene  <fabien.chene@gmail.com>
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv4.C
new file mode 100644 (file)
index 0000000..6584d28
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/43641
+// { dg-options "-std=c++0x" }
+
+struct B
+{
+  int i;
+};
+
+void func()
+{
+  [](const B& b) -> const int& { return b.i; };
+  [](const B& b) { return b; };
+}