]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56567 (ICE with lambda return type deduction and braced-init-list)
authorJason Merrill <jason@redhat.com>
Fri, 8 Mar 2013 15:55:18 +0000 (10:55 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 8 Mar 2013 15:55:18 +0000 (10:55 -0500)
PR c++/56567
* semantics.c (apply_deduced_return_type): Don't allow returning
std::initializer_list.

From-SVN: r196548

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

index 49e0f51bdec708016c31217dc975e3142e1013c0..14647610e4f19e7b6340116a5bb6da9b62bed5ff 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-08  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56567
+       * semantics.c (apply_deduced_return_type): Don't allow returning
+       std::initializer_list.
+
 2013-03-06  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/56534
index ab3d16ea3b805e677c1c75d55130a2f9d4fa71ed..d605de9631f87ed42c5ed6aff0055a96bbbe73fb 100644 (file)
@@ -9061,6 +9061,12 @@ 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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C
new file mode 100644 (file)
index 0000000..029287b
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/56567
+// { dg-require-effective-target c++11 }
+
+#include <initializer_list>
+
+int main()
+{
+  []{ return { 1, 2 }; }();    // { dg-error "initializer_list" }
+}
+
+// { dg-prune-output "return-statement with a value" }