From: Jakub Jelinek Date: Fri, 4 Apr 2008 13:07:27 +0000 (+0200) Subject: re PR c/35440 (ICE resulting in completely broken diagnostic) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=05008a0c3c6826ee6bc4b5d0368c068af1509d58;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e8c2155ac6..84852dbc1dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-04-04 Jakub Jelinek + + PR c/35440 + * c-pretty-print.c (pp_c_initializer_list): Handle CONSTRUCTOR + for all types. + 2008-04-04 Richard Guenther PR middle-end/35823 diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index c8443d31fcb..39044a3cebd 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1812cd2f53e..3a164ca31a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-04 Jakub Jelinek + + PR c/35440 + * gcc.dg/pr35440.c: New test. + 2008-04-04 Richard Guenther PR middle-end/35823 diff --git a/gcc/testsuite/gcc.dg/pr35440.c b/gcc/testsuite/gcc.dg/pr35440.c new file mode 100644 index 00000000000..796d7e0a9ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr35440.c @@ -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" } */ +}