re PR c/35440 (ICE resulting in completely broken diagnostic)

PR c/35440
	* c-pretty-print.c (pp_c_initializer_list): Handle CONSTRUCTOR
	for all types.

	* gcc.dg/pr35440.c: New test.

From-SVN: r133897
This commit is contained in:
Jakub Jelinek 2008-04-04 15:07:27 +02:00 committed by Jakub Jelinek
parent 5f4bebbf4e
commit 05008a0c3c
4 changed files with 30 additions and 5 deletions

View file

@ -1,3 +1,9 @@
2008-04-04 Jakub Jelinek <jakub@redhat.com>
PR c/35440
* c-pretty-print.c (pp_c_initializer_list): Handle CONSTRUCTOR
for all types.
2008-04-04 Richard Guenther <rguenther@suse.de>
PR middle-end/35823

View file

@ -1173,6 +1173,12 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
tree type = TREE_TYPE (e);
const enum tree_code code = TREE_CODE (type);
if (TREE_CODE (e) == CONSTRUCTOR)
{
pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
return;
}
switch (code)
{
case RECORD_TYPE:
@ -1207,16 +1213,12 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
case VECTOR_TYPE:
if (TREE_CODE (e) == VECTOR_CST)
pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
else if (TREE_CODE (e) == CONSTRUCTOR)
pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
else
break;
return;
case COMPLEX_TYPE:
if (TREE_CODE (e) == CONSTRUCTOR)
pp_c_constructor_elts (pp, CONSTRUCTOR_ELTS (e));
else if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
if (TREE_CODE (e) == COMPLEX_CST || TREE_CODE (e) == COMPLEX_EXPR)
{
const bool cst = TREE_CODE (e) == COMPLEX_CST;
pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));

View file

@ -1,3 +1,8 @@
2008-04-04 Jakub Jelinek <jakub@redhat.com>
PR c/35440
* gcc.dg/pr35440.c: New test.
2008-04-04 Richard Guenther <rguenther@suse.de>
PR middle-end/35823

View file

@ -0,0 +1,12 @@
/* PR c/35440 */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
struct A {};
struct B { int i; char j[2]; };
void foo (void)
{
(struct A){}(); /* { dg-error "called object" } */
(struct B){ .i = 2, .j[1] = 1 }(); /* { dg-error "called object" } */
}