re PR c++/43875 ([C++0x] ICE on invalid lambda return)
authorJason Merrill <jason@redhat.com>
Tue, 27 Apr 2010 21:21:35 +0000 (17:21 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 27 Apr 2010 21:21:35 +0000 (17:21 -0400)
PR c++/43875
* semantics.c (lambda_return_type): Complain about
braced-init-list.

From-SVN: r158805

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 68c6b498b74d53595ea04e2a0e57a232ee234ae8..0e1538ca6dfe34c56901ac1d3eb5457dbcebbf19 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 ea01eb313783d0c9ce57e789641eda59aaa55668..05c516870a948db0990634b4ebad6d96bc8d94f6 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 4a8fb182f770b65da910eef7f2ef8fd6dc9353b4..0746e595468220bbcb2d47f41053d34c28f87277 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" }
+}