diff options
author | John Levon <levon@movementarian.org> | 2018-11-29 10:42:27 +0000 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-11-29 23:48:21 +0100 |
commit | d3038d8fce94959bc9bcbcff698d272d0f610364 (patch) | |
tree | 0cfd3d389d22fa944c8d8785e39524f6688d6356 | |
parent | 756844b2a77ddf5396891cb4dd055de315dfdfdc (diff) | |
download | sparse-d3038d8fce94959bc9bcbcff698d272d0f610364.tar.gz |
Ignore #ident directives
Legacy code can be littered with the non-standard "#ident" directive;
ignore it.
Signed-off-by: John Levon <levon@movementarian.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | pre-process.c | 6 | ||||
-rw-r--r-- | validation/preprocessor/ident-pragma.c | 12 | ||||
-rw-r--r-- | validation/preprocessor/ident.c | 12 |
3 files changed, 30 insertions, 0 deletions
diff --git a/pre-process.c b/pre-process.c index bf4b8e76..1ed7a47c 100644 --- a/pre-process.c +++ b/pre-process.c @@ -1977,6 +1977,11 @@ static int handle_line(struct stream *stream, struct token **line, struct token return 1; } +static int handle_ident(struct stream *stream, struct token **line, struct token *token) +{ + return 1; +} + static int handle_nondirective(struct stream *stream, struct token **line, struct token *token) { sparse_error(token->pos, "unrecognized preprocessor line '%s'", show_token_sequence(token, 0)); @@ -2003,6 +2008,7 @@ static void init_preprocessor(void) { "include_next", handle_include_next }, { "pragma", handle_pragma }, { "line", handle_line }, + { "ident", handle_ident }, // our internal preprocessor tokens { "nostdinc", handle_nostdinc }, diff --git a/validation/preprocessor/ident-pragma.c b/validation/preprocessor/ident-pragma.c new file mode 100644 index 00000000..81abdd7b --- /dev/null +++ b/validation/preprocessor/ident-pragma.c @@ -0,0 +1,12 @@ +#pragma ident "foo" + +/* + * check-description: check that '#pragma ident ... " is ignored. + * check-name: ident-pragma + * check-command: sparse -E $file + * + * check-output-start + + + * check-output-end + */ diff --git a/validation/preprocessor/ident.c b/validation/preprocessor/ident.c new file mode 100644 index 00000000..3e7f3ad0 --- /dev/null +++ b/validation/preprocessor/ident.c @@ -0,0 +1,12 @@ +#ident "foo" + +/* + * check-description: check that the non-standard "#ident ..." is ignored. + * check-name: ident + * check-command: sparse -E $file + * + * check-output-start + + + * check-output-end + */ |