As Paul Eggert says in the PR, we shouldn't warn for enum bit-fields in C99/C11 mode. C11 6.7.2.1 (5) says "A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed int, unsigned int, or some other implementation-defined type.", so ISTM that enum bit-fields should be fine. OTOH, I would warn in ISO C mode. It's true that no constraint is violated, but in C89 in 3.5.2.1 Semantics there's: "A bit-field may have type int, unsigned int, or signed int." so it seems desirable to warn in this case.
Regtested/bootstrapped on x86_64-linux, ok for trunk? 2014-01-03 Marek Polacek <pola...@redhat.com> PR c/57773 c/ * c-decl.c (check_bitfield_type_and_width): Warn for enum bit-fields only in ISO C. testsuite/ * gcc.dg/pr57773.c: New test. --- gcc/c/c-decl.c.mp 2014-01-03 13:50:37.041997222 +0100 +++ gcc/c/c-decl.c 2014-01-03 14:46:29.115816235 +0100 @@ -4840,7 +4840,8 @@ check_bitfield_type_and_width (tree *typ if (!in_system_header_at (input_location) && type_mv != integer_type_node && type_mv != unsigned_type_node - && type_mv != boolean_type_node) + && type_mv != boolean_type_node + && !flag_isoc99) pedwarn (input_location, OPT_Wpedantic, "type of bit-field %qs is a GCC extension", name); --- gcc/testsuite/gcc.dg/pr57773.c.mp 2014-01-03 14:50:51.097902818 +0100 +++ gcc/testsuite/gcc.dg/pr57773.c 2014-01-03 14:49:05.727462306 +0100 @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Wpedantic" } */ + +enum e { zero }; +struct { enum e field: 2; } s; Marek