This series fixes several problems about sparse's base type for enums. The goal is two fold: 1) if possible stay compatible with GCC 2) prepare to have stronger, stricter enum types: -) where the enumerators have the enum type -) enumrs are not compatible with their base type. and the possibility to declare bitwise enum types. This series should be considered as a preparatory step for the second goal. With these patches the rules for an enum's base type are: 1) if all enumerators are of the same restricted type, then the base type is this restricted type 2) if all the enumerators have an (non-restricted) integer type, then the base type will be the smallest integer type at least as big as 'int' and able to hold all the values of the enum (so, first int, unsigned int, long, unsigned int, ...). 3) an enumerator without initializer is considered as being a non-restricted type. 4) non-integer or non-constant initializers are invalid 5) temporary, if the enumerators mix restricted and non-restricted types, each enumerator keep their original type and a warning is issued. Note: This is to keep compatibility with (a few) such uses in the kernel. 6) otherwise, the enum is invalid. The differences with GCC are: a) GCC favor unsigned types for enum's base types b) irrespectively of a) GCC force to 'int' enumerators that fit in a int (the justification being to avoid promotions to unsigned types when comparing such enumerators with (signed) integers). So, yes, an enumerator will either have the same type as the enum base type or 'int' if it fit in an 'int'. This series is available for review & testing in the Git repository at: git://github.com/lucvoo/sparse-dev.git fix-enum-type Luc Van Oostenryck (9): enum: add testcase for type of enum members enum: add testcase for base & enumerator type enum: fix cast_enum_list() enum: use the smallest type that fit enum: use the values to determine the base type enum: only warn (once) when mixing bitwiseness enum: warn when mixing different restricted types enum: warn on bad enums enum: rewrite bound checking parse.c | 117 +++++++++++++------------------ validation/enum-base-type.c | 28 ++++++++ validation/enum-bitwise-bad.c | 20 ++++++ validation/enum-bitwise-mixed.c | 29 ++++++++ validation/enum-bitwise.c | 19 +++++ validation/enum-bounds.c | 23 ++++++ validation/enum-init-constness.c | 9 +++ validation/enum-invalid.c | 11 +++ validation/enum-min-size.c | 29 ++++++++ validation/enum-same-type.c | 14 ++++ validation/enum-sign-gcc.c | 63 +++++++++++++++++ validation/enum-typecheck.c | 39 +++++++++++ 12 files changed, 334 insertions(+), 67 deletions(-) create mode 100644 validation/enum-base-type.c create mode 100644 validation/enum-bitwise-bad.c create mode 100644 validation/enum-bitwise-mixed.c create mode 100644 validation/enum-bitwise.c create mode 100644 validation/enum-bounds.c create mode 100644 validation/enum-init-constness.c create mode 100644 validation/enum-invalid.c create mode 100644 validation/enum-min-size.c create mode 100644 validation/enum-same-type.c create mode 100644 validation/enum-sign-gcc.c create mode 100644 validation/enum-typecheck.c -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html