[C PATCH] Don't pedwarn for C99/C11 enum bit-fields (PR c/57773)

Joseph S. Myers joseph@codesourcery.com
Fri Jan 3 17:17:00 GMT 2014


On Fri, 3 Jan 2014, Marek Polacek wrote:

> 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?

Implementation-defined behavior is documented in implement-c.texi, so this 
patch is incomplete as it doesn't update that file where it says:

    No other types are permitted in strictly conforming mode.
    @c Would it be better to restrict the pedwarn for other types to C90
    @c mode and document the other types for C99/C11 mode?

(And this isn't just about enums, but other integer types as well, so the 
test should cover those.)

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list