parser: Remove the unused attribute alignment from struct declaration_specifiers_t.
[cparser] / warning.h
index 68ba6dd..b0cd192 100644 (file)
--- a/warning.h
+++ b/warning.h
@@ -1,21 +1,6 @@
 /*
  * This file is part of cparser.
- * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * Copyright (C) 2012 Matthias Braun <matze@braunis.de>
  */
 #ifndef WARNING_H
 #define WARNING_H
@@ -46,6 +31,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 +40,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,12 +79,14 @@ 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
        WARN_STRICT_PROTOTYPES,             /**< Warn if a function declaration has an unspecified parameter list */
        WARN_SWITCH_DEFAULT,                /**< Warn whenever a 'switch' statement does not have a 'default' case */
        WARN_SWITCH_ENUM,                   /**< Warn about 'switch' statements with an enum as index type and missing case labels or case labels outside the enum range TODO has an alias -Wswitch? */
+       WARN_SYSTEM,                        /**< Show warnings in system headers. */
        WARN_TRADITIONAL,                   /**< Warn about certain constructs that behave differently in traditional and ISO C */
 #if 0 // TODO
        WARN_UNDEF,                         /**< Warn if an undefined identifier is evaluated in an '#if' directive */
@@ -114,14 +102,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 +118,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