From 2aa953d015925abcd909e22ec48507660efe30aa Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 11 Mar 2013 12:22:16 -0400 Subject: [PATCH] re PR c++/56567 (ICE with lambda return type deduction and braced-init-list) 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 | 6 ++++++ gcc/cp/semantics.c | 6 ------ gcc/cp/typeck.c | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f09fa0a8327..c728c50c587 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-03-11 Jason Merrill + + 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 PR c++/51412 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 233765a936f..e909b984681 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 58295d73d15..58ebcc0ab2d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -8136,6 +8136,11 @@ check_return_expr (tree retval, bool *no_warning) "deduced to %"); type = error_mark_node; } + else if (retval && BRACE_ENCLOSED_INITIALIZER_P (retval)) + { + error ("returning initializer list"); + type = error_mark_node; + } else { if (!retval) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C index 029287bd148..f7b82efe97c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C @@ -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" } -- 2.30.2