From 97471c71bfe5d692043166106599eca3374b0370 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 17 Nov 2009 20:03:03 +0000 Subject: re PR c++/42058 (Trouble with invalid array initialization) cp/ 2009-11-17 Paolo Carlini PR c++/42058 * typeck2.c (digest_init_r): Check init for error_operand_p. * decl.c (reshape_init_class): Check return value of reshape_init_r for error_mark_node. testsuite/ 2009-11-17 Paolo Carlini PR c++/42058 * testsuite/g++.dg/init/array26.C: New. * testsuite/g++.dg/init/array27.C: Likewise. * testsuite/g++.old-deja/g++.benjamin/13478.C: Adjust dg-errors. From-SVN: r154267 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl.c | 3 +++ gcc/cp/typeck2.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f5f9b5..17968f5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-11-17 Paolo Carlini + + PR c++/42058 + * typeck2.c (digest_init_r): Check init for error_operand_p. + * decl.c (reshape_init_class): Check return value of reshape_init_r + for error_mark_node. + 2009-11-17 Jakub Jelinek PR c++/42061 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 851edeb..f57efb7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4878,6 +4878,9 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p) field_init = reshape_init_r (TREE_TYPE (field), d, /*first_initializer_p=*/false); + if (field_init == error_mark_node) + return error_mark_node; + CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_init), field, field_init); /* [dcl.init.aggr] diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 96fa442..6cb1152 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -723,7 +723,7 @@ digest_init_r (tree type, tree init, bool nested, int flags) { enum tree_code code = TREE_CODE (type); - if (init == error_mark_node) + if (error_operand_p (init)) return error_mark_node; gcc_assert (init); -- cgit v1.1