renamed format option, added nonnull option
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 19 Mar 2008 11:16:17 +0000 (11:16 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 19 Mar 2008 11:16:17 +0000 (11:16 +0000)
[r18985]

format_check.c
warning.c
warning.h

index 99edcce..9c8710b 100644 (file)
@@ -540,7 +540,7 @@ next_arg:
 
 void check_format(const call_expression_t *const call)
 {
-       if (!warning.check_format)
+       if (!warning.format)
                return;
 
        const expression_t *const func_expr = call->function;
index ebf5f6a..c93ed20 100644 (file)
--- a/warning.c
+++ b/warning.c
@@ -24,7 +24,8 @@
 warning_t warning = {
        .attribute                     = true,
        .char_subscripts               = true,
-       .check_format                  = true,
+       .format                        = true,
+       .nonnull                       = true,
        .empty_statement               = false,
        .fatal_errors                  = false,
        .float_equal                   = false,
@@ -68,7 +69,8 @@ void set_warning_opt(const char *const opt)
                /* Note: this switched on a lot of more warnings than gcc's -Wall */
                SET(attribute)
                SET(char_subscripts)
-               SET(check_format)
+               SET(format)
+               SET(nonnull)
                SET(empty_statement)
                SET(implicit_function_declaration)
                SET(implicit_int)
@@ -100,7 +102,11 @@ void set_warning_opt(const char *const opt)
        }
        OPT("fatal-errors",                  fatal_errors)
        OPT("float-equal",                   float_equal)
-       OPT("format",                        check_format)
+       OPTX("format") {
+               SET(format)
+               SET(nonnull)
+       }
+       OPT("nonnull",                       nonnull)
        OPTX("implicit") {
                SET(implicit_function_declaration)
                SET(implicit_int)
index 743e420..3b3f22f 100644 (file)
--- a/warning.h
+++ b/warning.h
@@ -31,7 +31,8 @@ typedef struct warning_t {
 #endif
        bool attribute:1;                     /**< Warn if an unexpected `__attribute__' is used or function attributes applied to variables, etc. */
        bool char_subscripts:1;               /**< Warn if an array subscript has the type 'char' */
-       bool check_format:1;                  /**< Check printf-style format strings */
+       bool format:1;                        /**< Check printf-style format strings */
+       bool nonnull:1;                       /**< Warn about passing a null pointer for arguments marked nonnull */
 #if 0 // TODO
        bool cast_align:1;                    /**< Warn whenever a pointer is cast such that the required alignment of the target is increased */
        bool cast_qual:1;                     /**< Warn whenever a pointer is cast so as to remove a type qualifier from the target type */