From: Jakub Jelinek Date: Tue, 17 Nov 2009 07:01:18 +0000 (+0100) Subject: re PR c++/42061 ([c++0x] ICE with invalid initializer list for reference) X-Git-Tag: releases/gcc-4.5.0~2318 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d22f0231e60287574538fc60f743f9464a0977f4;p=thirdparty%2Fgcc.git re PR c++/42061 ([c++0x] ICE with invalid initializer list for reference) PR c++/42061 * call.c (reference_binding): Return NULL for initializer list with error operand inside of it. * g++.dg/cpp0x/initlist27.C: New test. From-SVN: r154238 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1db746c7946..4f5f9b542489 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2009-11-17 Jakub Jelinek + PR c++/42061 + * call.c (reference_binding): Return NULL for initializer list with + error operand inside of it. + PR c++/42059 * typeck.c (cp_build_modify_expr): For initializer list call check_array_initializer to make sure lhs isn't a VLA. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e4a6bca347fb..e051e907220e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1235,6 +1235,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) && CONSTRUCTOR_NELTS (expr) == 1) { expr = CONSTRUCTOR_ELT (expr, 0)->value; + if (error_operand_p (expr)) + return NULL; from = TREE_TYPE (expr); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 325bcf9b53b5..f73a427fa096 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2009-11-17 Jakub Jelinek + PR c++/42061 + * g++.dg/cpp0x/initlist27.C: New test. + PR c++/42059 * g++.dg/cpp0x/initlist26.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist27.C b/gcc/testsuite/g++.dg/cpp0x/initlist27.C new file mode 100644 index 000000000000..f8536d3e7e7f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist27.C @@ -0,0 +1,5 @@ +// PR c++/42061 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +int& i = { j }; // { dg-error "invalid initialization|was not declared" }