sparse: add -Wno-non-ansi-function-declaration
PATCH 6/18 sparse: add -Wno-non-ansi-function-declaration
Signed-off-by John Levon <[email protected]>
--- cgcc | 2 +- lib.c | 2 ++ lib.h | 1 + parse.c | 11 +++++++---- sparse.1 | 7 +++++++ validation/non-ansi-function-declaration.c | 10 ++++++++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 validation/non-ansi-function-declaration.c
cgcc +1 -1
@@ -101,7 +101,7 @@ exit 0; sub check_only_option { my ($arg) = @_; - return 1 if $arg =~ /^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/; + return 1 if $arg =~ /^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-ansi-function-declaration|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/; return 1 if $arg =~ /^-v(no-?)?(entry|dead)$/; return 1 if $arg =~ /^-f(dump-linearize|memcpy-max-count)(=\S*)?$/; return 0;
lib.c +2 -0
@@ -237,6 +237,7 @@ int Winit_cstring = 0;int Wenum_mismatch =1 ;int Wsparse_error =0 ;int Wmemcpy_max_count =1 ; +int Wnon_ansi_function_declaration =1 ;int Wnon_pointer_null =1 ;int Wold_initializer =1 ;int Wone_bit_signed_bitfield =1 ;
@@ -539,6 +540,7 @@ static const struct warning { { "enum-mismatch", &Wenum_mismatch }, { "init-cstring", &Winit_cstring }, { "memcpy-max-count", &Wmemcpy_max_count }, + { "non-ansi-function-declaration", &Wnon_ansi_function_declaration }, { "non-pointer-null", &Wnon_pointer_null }, { "old-initializer", &Wold_initializer }, { "one-bit-signed-bitfield", &Wone_bit_signed_bitfield },
lib.h +1 -0
@@ -128,6 +128,7 @@ extern int Wenum_mismatch;extern int Wsparse_error;extern int Winit_cstring;extern int Wmemcpy_max_count; +extern int Wnon_ansi_function_declaration;extern int Wnon_pointer_null;extern int Wold_initializer;extern int Wone_bit_signed_bitfield;
parse.c +7 -4
@@ -1698,9 +1698,10 @@ static enum kind which_func(struct token *token,/* don't complain about those */ if (!n ||match_op (next->next,';' ))return Empty; -warning (next->pos, -"non-ANSI function declaration of function '%s'" , -show_ident (*n)); +if (Wnon_ansi_function_declaration) +warning (next->pos, +"non-ANSI function declaration of function '%s'" , +show_ident (*n));return Empty; }
@@ -2783,7 +2784,9 @@ static struct token *parse_k_r_arguments(struct token *token, struct symbol *dec {struct symbol_list *args =NULL ; -warning (token->pos,"non-ANSI definition of function '%s'" ,show_ident (decl->ident)); +if (Wnon_ansi_function_declaration) +warning (token->pos,"non-ANSI definition of function '%s'" ,show_ident (decl->ident)); + do { token = declaration_list(token, &args); if (!match_op(token, ';')) {
sparse.1 +7 -0
@@ -230,6 +230,13 @@ The limit can be changed with \fB\-fmemcpy\-max\-count=COUNT\fR, the default being \fB100000\fR. . .TP +.B \-Wnon\-ansi\-function\-declaration +Warn about non-ANSI function declarations. + +Sparse issues these warnings by default. To turn them off, use +\fB\-Wno\-non\-ansi\-function\-declaration\fR. +. +.TP .B \-Wnon\-pointer\-null Warn about the use of 0 as a NULL pointer.
validation/non-ansi-function-declaration.c new file +10 -0
@@ -0,0 +1,10 @@ + + +extern void myfunction (),myfunc2 (); + +/* +* check-name: -Wno-non-ansi-function-declaration works +* check-command: sparse -Wno-non-ansi-function-declaration $file +* check-error-start +* check-error-end +*/
Signature · 1 line
2.14.1