X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=warning.h;h=dcd2bd9c75a9467ff67762b7170c40f370c47288;hb=59314ed9eb7b881052ae37fd05be224795cbd616;hp=68ba6dd8c03140e0e85401129c2581bfcf19d7dc;hpb=bb8544d38aaa4c716603a5d565c3ff3840454ffc;p=cparser diff --git a/warning.h b/warning.h index 68ba6dd..dcd2bd9 100644 --- a/warning.h +++ b/warning.h @@ -46,6 +46,7 @@ typedef enum warning_t { WARN_DECLARATION_AFTER_STATEMENT, /**< Warn when a declaration is found after a statement in a block */ WARN_DEPRECATED_DECLARATIONS, /* TODO implement for types */ /**< Warn about uses of functions, variables and types marked as deprecated by using the 'deprecated' attribute */ WARN_DIV_BY_ZERO, /**< Warn about compile-time integer division by zero */ + WARN_EMPTY_BODY, /**< Warn about an empty body of an if or else statement */ WARN_EMPTY_STATEMENT, /**< Warn about empty statements, i.e. lone ';' */ #if 0 // TODO WARN_ENDIF_LABELS, /**< Warn whenever an '#else' or an '#endif' are followed by text */ @@ -54,9 +55,9 @@ typedef enum warning_t { WARN_FATAL_ERRORS, /**< First error stops the compilation */ WARN_FLOAT_EQUAL, /**< Warn if floating point values are used in equality comparisons */ WARN_FORMAT, /**< Check printf-style format strings */ + WARN_IGNORED_QUALIFIERS, /**< Warn when type qualifiers are meaningless */ WARN_IMPLICIT_FUNCTION_DECLARATION, /**< Warn whenever a function is used before being declared */ WARN_IMPLICIT_INT, /**< Warn when a declaration does not specify a type */ - WARN_INIT_SELF, /**< Warn about uninitialized variables which are initialized with themselves. */ #if 0 // TODO WARN_INLINE, /**< Warn if a function can not be inlined and it was declared as inline */ WARN_INT_TO_POINTER_CAST, /**< Warn if cast from integer to pointer of different size. */ @@ -93,6 +94,7 @@ typedef enum warning_t { WARN_SHADOW, /**< Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed */ WARN_SHADOW_LOCAL, WARN_SIGN_COMPARE, /**< Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned */ + WARN_STRAY_SEMICOLON, /**< Warn about stray semicolons outside of functions */ #if 0 // TODO WARN_STRICT_ALIASING, /**< Warn about code which might break the strict aliasing rules that the compiler is using for optimization. */ #endif @@ -114,14 +116,15 @@ typedef enum warning_t { WARN_WRITE_STRINGS, /**< Give string constants the type 'const char[LENGTH]' so that copying the address of one into a 'char *' pointer will get a warning */ } warning_t; -typedef enum warn_level_t { - WARN_LEVEL_OFF, - WARN_LEVEL_ON, - WARN_LEVEL_ERROR -} warn_level_t; +typedef enum warn_state_t { + WARN_STATE_NONE = 0, + WARN_STATE_ON = 1U << 0, + WARN_STATE_ERROR = 1U << 1, + WARN_STATE_NO_ERROR = 1U << 2 +} warn_state_t; typedef struct warning_switch_t { - warn_level_t level; + warn_state_t state; char const* const name; } warning_switch_t; @@ -129,7 +132,7 @@ warning_switch_t const *get_warn_switch(warning_t); static inline bool is_warn_on(warning_t const warn) { - return get_warn_switch(warn)->level != WARN_LEVEL_OFF; + return get_warn_switch(warn)->state & WARN_STATE_ON; } #endif