OSDN Git Service

PR c++/43875
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Apr 2010 21:21:35 +0000 (21:21 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 04:52:24 +0000 (13:52 +0900)
* semantics.c (lambda_return_type): Complain about
braced-init-list.

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

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

index 68c6b49..0e1538c 100644 (file)
@@ -1,5 +1,9 @@
 2010-04-27  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43875
+       * semantics.c (lambda_return_type): Complain about
+       braced-init-list.
+
        PR c++/43790
        * tree.c (cv_unqualified): Handle error_mark_node.
 
index ea01eb3..05c5168 100644 (file)
@@ -5521,6 +5521,11 @@ tree
 lambda_return_type (tree expr)
 {
   tree type;
+  if (BRACE_ENCLOSED_INITIALIZER_P (expr))
+    {
+      warning (0, "cannot deduce lambda return type from a braced-init-list");
+      return void_type_node;
+    }
   if (type_dependent_expression_p (expr))
     {
       type = cxx_make_type (DECLTYPE_TYPE);
index 4a8fb18..0746e59 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/43875
+       * g++.dg/cpp0x/lambda/lambda-deduce2.C: New.
+
 2010-04-27  Manuel López-Ibáñez  <manu@gcc.gnu.org>
            Jan Hubicka <hubicka@ucw.cz>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C
new file mode 100644 (file)
index 0000000..718d49c
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/43875
+// { dg-options "-std=c++0x" }
+
+int main()
+{
+   auto x2 = []{ return { 1, 2 }; }; // { dg-message "return" }
+}