From 95b24c84c3d66cba21214df45e041ed9a8bd6be1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 27 Apr 2010 17:21:35 -0400 Subject: re PR c++/43875 ([C++0x] ICE on invalid lambda return) PR c++/43875 * semantics.c (lambda_return_type): Complain about braced-init-list. From-SVN: r158805 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/semantics.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C | 7 +++++++ 4 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 68c6b49..0e1538c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-04-27 Jason Merrill + PR c++/43875 + * semantics.c (lambda_return_type): Complain about + braced-init-list. + PR c++/43790 * tree.c (cv_unqualified): Handle error_mark_node. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ea01eb3..05c5168 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a8fb18..0746e59 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-27 Jason Merrill + + PR c++/43875 + * g++.dg/cpp0x/lambda/lambda-deduce2.C: New. + 2010-04-27 Manuel López-Ibáñez Jan Hubicka 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 index 0000000..718d49c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C @@ -0,0 +1,7 @@ +// PR c++/43875 +// { dg-options "-std=c++0x" } + +int main() +{ + auto x2 = []{ return { 1, 2 }; }; // { dg-message "return" } +} -- cgit v1.1