re PR c/35440 (ICE resulting in completely broken diagnostic)
authorJakub Jelinek <jakub@redhat.com>
Fri, 4 Apr 2008 13:07:27 +0000 (15:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 4 Apr 2008 13:07:27 +0000 (15:07 +0200)
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

gcc/ChangeLog
gcc/c-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr35440.c [new file with mode: 0644]

index 8e8c2155ac6dcbbcbb6217ba9b0d921c8a50d296..84852dbc1dd9a55e287bdf19884da7f1c9da48e6 100644 (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
index c8443d31fcb1c9524fad82e5ac93e00e27038cea..39044a3cebd975aeec12e7727d8843b6876f6925 100644 (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));
index 1812cd2f53e79c81ab26f2a8a78a6cb5a654e28b..3a164ca31a041a1beffbabd0dcd2a5bc4219bdf9 100644 (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
diff --git a/gcc/testsuite/gcc.dg/pr35440.c b/gcc/testsuite/gcc.dg/pr35440.c
new file mode 100644 (file)
index 0000000..796d7e0
--- /dev/null
@@ -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" } */
+}