From: Jason Merrill Date: Fri, 8 Mar 2013 15:55:18 +0000 (-0500) Subject: re PR c++/56567 (ICE with lambda return type deduction and braced-init-list) X-Git-Tag: releases/gcc-4.8.0~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e48243d8403c76cd248a97c94d138936d856d543;p=thirdparty%2Fgcc.git re PR c++/56567 (ICE with lambda return type deduction and braced-init-list) PR c++/56567 * semantics.c (apply_deduced_return_type): Don't allow returning std::initializer_list. From-SVN: r196548 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49e0f51bdec7..14647610e4f1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-03-08 Jason Merrill + + PR c++/56567 + * semantics.c (apply_deduced_return_type): Don't allow returning + std::initializer_list. + 2013-03-06 Paolo Carlini PR c++/56534 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ab3d16ea3b80..d605de9631f8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 index 000000000000..029287bd1480 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C @@ -0,0 +1,11 @@ +// PR c++/56567 +// { dg-require-effective-target c++11 } + +#include + +int main() +{ + []{ return { 1, 2 }; }(); // { dg-error "initializer_list" } +} + +// { dg-prune-output "return-statement with a value" }