re PR c++/42058 (Trouble with invalid array initialization)

cp/
2009-11-17  Paolo Carlini  <paolo.carlini@oracle.com>

	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  <paolo.carlini@oracle.com>

	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
This commit is contained in:
Paolo Carlini 2009-11-17 20:03:03 +00:00 committed by Paolo Carlini
parent 6bab028494
commit 97471c71bf
7 changed files with 41 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2009-11-17 Paolo Carlini <paolo.carlini@oracle.com>
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 <jakub@redhat.com>
PR c++/42061

View File

@ -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]

View File

@ -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);

View File

@ -1,3 +1,10 @@
2009-11-17 Paolo Carlini <paolo.carlini@oracle.com>
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.
2009-11-17 Jakub Jelinek <jakub@redhat.com>
PR c++/42061

View File

@ -0,0 +1,11 @@
// PR c++/42058
// { dg-options "" }
struct A;
struct B
{
A a; // { dg-error "incomplete type" }
};
B b[1] = (B[]) { 0 }; // { dg-error "initializer" }

View File

@ -0,0 +1,11 @@
// PR c++/42058
// { dg-options "" }
struct A {};
struct B
{
A a;
};
B b[1] = (B[]) { 0 }; // { dg-error "initializer" }

View File

@ -27,10 +27,4 @@ const hand_table Agent::table_1[] =
{0, &Agent::table_2},
{first, &Agent::foo},
{last, &(hand)Agent::foo} // { dg-error "" } no match
}; // { dg-error "" } cannot convert
};