diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-03-12 02:01:34 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-03-15 23:52:29 +0100 |
commit | 6e5fbe9870a8a593230a16cafc2de69aa2b91f78 (patch) | |
tree | 94b38d9caf64d4cdf0819b3fe83aed6834484992 | |
parent | 5c2338f694cda83c28a96e198f8de13bc1cde8b4 (diff) | |
download | sparse-6e5fbe9870a8a593230a16cafc2de69aa2b91f78.tar.gz |
cpp: remove extra newlines during macro expansion
During macro expansion, Sparse doesn't strip newlines from
the arguments as required by 6.10.3p10 and done by gcc & clang.
So, remove these newlines.
Note: the current behaviour may make the preprocessed output
more readable (and so may be considered as a feature).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | pre-process.c | 1 | ||||
-rw-r--r-- | validation/preprocessor/directive-within-macro.c | 8 | ||||
-rw-r--r-- | validation/preprocessor/expand-and-nl.c | 13 | ||||
-rw-r--r-- | validation/preprocessor/preprocessor22.c | 4 |
4 files changed, 17 insertions, 9 deletions
diff --git a/pre-process.c b/pre-process.c index a5a3c5fb..f2053676 100644 --- a/pre-process.c +++ b/pre-process.c @@ -309,6 +309,7 @@ static struct token *collect_arg(struct token *prev, int vararg, struct position next->pos.stream = pos->stream; next->pos.line = pos->line; next->pos.pos = pos->pos; + next->pos.newline = 0; p = &next->next; } *p = &eof_token_entry; diff --git a/validation/preprocessor/directive-within-macro.c b/validation/preprocessor/directive-within-macro.c index 5269d4a7..4562078a 100644 --- a/validation/preprocessor/directive-within-macro.c +++ b/validation/preprocessor/directive-within-macro.c @@ -26,12 +26,8 @@ f(1 * * check-output-start -1 -a -d -3 -1 -3 +1 a d 3 +1 3 * check-output-end * * check-error-start diff --git a/validation/preprocessor/expand-and-nl.c b/validation/preprocessor/expand-and-nl.c new file mode 100644 index 00000000..1a5f2265 --- /dev/null +++ b/validation/preprocessor/expand-and-nl.c @@ -0,0 +1,13 @@ +#define M(X) X-X + +M(a +b) +/* + * check-name: expand-and-nl + * check-command: sparse -E $file + * + * check-output-start + +a b-a b + * check-output-end + */ diff --git a/validation/preprocessor/preprocessor22.c b/validation/preprocessor/preprocessor22.c index 11f625c0..0d13c5f8 100644 --- a/validation/preprocessor/preprocessor22.c +++ b/validation/preprocessor/preprocessor22.c @@ -28,8 +28,6 @@ preprocessor/preprocessor22.c:12:1: warning: directive in macro's argument list * * check-output-start -struct { -int b; -} a;; +struct { int b; } a;; * check-output-end */ |