OSDN Git Service

PR c/40032
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 May 2009 13:02:48 +0000 (13:02 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 May 2009 13:02:48 +0000 (13:02 +0000)
* c-decl.c (grokdeclarator): Handle incomplete type of unnamed
field.

testsuite:
* gcc.dg/noncompile/incomplete-5.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147174 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/incomplete-5.c [new file with mode: 0644]

index 9ab24db..9d53da0 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-06  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/40032
+       * c-decl.c (grokdeclarator): Handle incomplete type of unnamed
+       field.
+
 2009-05-05  Jakub Jelinek  <jakub@redhat.com>
 
        * tree.h: Remove DECL_BY_REFERENCE from private_flag comment.
index a851c6d..85c4d6b 100644 (file)
@@ -5021,7 +5021,10 @@ grokdeclarator (const struct c_declarator *declarator,
        else if (TREE_CODE (type) != ERROR_MARK
                 && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type))
          {
-           error ("field %qE has incomplete type", name);
+           if (name)
+             error ("field %qE has incomplete type", name);
+           else
+             error ("unnamed field has incomplete type");
            type = error_mark_node;
          }
        type = c_build_qualified_type (type, type_quals);
index e5a6e5e..880a5d4 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-06  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/40032
+       * gcc.dg/noncompile/incomplete-5.c: New test.
+
 2009-05-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/39666
diff --git a/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c b/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c
new file mode 100644 (file)
index 0000000..049c34a
--- /dev/null
@@ -0,0 +1,8 @@
+/* ICE on unnamed field with incomplete enum type: PR 40032.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+struct A
+{
+  enum E : 8; /* { dg-warning "narrower than values of its type" } */
+  /* { dg-error "has incomplete type" "incomplete" { target *-*-* } 6 } */
+};