diff options
author | Jason Merrill <jason@redhat.com> | 2013-03-08 10:55:18 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-03-08 10:55:18 -0500 |
commit | e48243d8403c76cd248a97c94d138936d856d543 (patch) | |
tree | e5eac51dcae07a90843bfa7d6d8587831033307c | |
parent | ecd4f20a204c654c02e2916e1dd191352f2a0ace (diff) | |
download | gcc-e48243d8403c76cd248a97c94d138936d856d543.zip gcc-e48243d8403c76cd248a97c94d138936d856d543.tar.gz gcc-e48243d8403c76cd248a97c94d138936d856d543.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-initlist3.C | 11 |
3 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49e0f51..1464761 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ab3d16e..d605de9 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 0000000..029287b --- /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 <initializer_list> + +int main() +{ + []{ return { 1, 2 }; }(); // { dg-error "initializer_list" } +} + +// { dg-prune-output "return-statement with a value" } |