re PR c++/56567 (ICE with lambda return type deduction and braced-init-list)
authorJason Merrill <jason@redhat.com>
Mon, 11 Mar 2013 16:22:16 +0000 (12:22 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 11 Mar 2013 16:22:16 +0000 (12:22 -0400)
PR c++/56567
* typeck.c (check_return_expr): Disallow returning init list here.
* semantics.c (apply_deduced_return_type): Not here.

From-SVN: r196600

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C

index f09fa0a8327c5f9cba3ac9db455bb115910c1d66..c728c50c587ef6fc39f290f6481420ff8da058f3 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-11  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56567
+       * typeck.c (check_return_expr): Disallow returning init list here.
+       * semantics.c (apply_deduced_return_type): Not here.
+
 2013-03-08  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51412
index 233765a936f9c8c7cddcadbb5d6db4233a9e94eb..e909b984681024d48162adf3023902a39665af77 100644 (file)
@@ -9061,12 +9061,6 @@ apply_deduced_return_type (tree fco, tree return_type)
   if (return_type == error_mark_node)
     return;
 
-  if (is_std_init_list (return_type))
-    {
-      error ("returning %qT", return_type);
-      return_type = void_type_node;
-    }
-
   if (LAMBDA_FUNCTION_P (fco))
     {
       tree lambda = CLASSTYPE_LAMBDA_EXPR (current_class_type);
index 58295d73d15f9ea9e348672474534d0d8dd05ef8..58ebcc0ab2d1b7d52ba2d4077138d9755c5ce1e2 100644 (file)
@@ -8136,6 +8136,11 @@ check_return_expr (tree retval, bool *no_warning)
                  "deduced to %<void%>");
          type = error_mark_node;
        }
+      else if (retval && BRACE_ENCLOSED_INITIALIZER_P (retval))
+       {
+         error ("returning initializer list");
+         type = error_mark_node;
+       }
       else
        {
          if (!retval)
index 029287bd1480f9eb922b8d6302f5ed36bef05e3a..f7b82efe97c902f6dae043fd791d5c04d37411f3 100644 (file)
@@ -5,7 +5,7 @@
 
 int main()
 {
-  []{ return { 1, 2 }; }();    // { dg-error "initializer_list" }
+  []{ return { 1, 2 }; }();    // { dg-error "initializer.list" }
 }
 
 // { dg-prune-output "return-statement with a value" }