diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9ab24dbad9e..9d53da037c8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-05-06 Joseph Myers + + PR c/40032 + * c-decl.c (grokdeclarator): Handle incomplete type of unnamed + field. + 2009-05-05 Jakub Jelinek * tree.h: Remove DECL_BY_REFERENCE from private_flag comment. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index a851c6de152..85c4d6bf02d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e5a6e5e2549..880a5d4d670 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-05-06 Joseph Myers + + PR c/40032 + * gcc.dg/noncompile/incomplete-5.c: New test. + 2009-05-05 Jakub Jelinek 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 index 00000000000..049c34a20a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/incomplete-5.c @@ -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 } */ +};