[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-sparse
Subject: [RFC] cpp: remove extra newlines during macro expansion
From: Luc Van Oostenryck <luc.vanoostenryck () gmail ! com>
Date: 2020-03-12 20:25:33
Message-ID: 20200312202533.52465-1-luc.vanoostenryck () gmail ! com
[Download RAW message or body]
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>
---
pre-process.c | 1 +
validation/preprocessor/expand-and-nl.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
create mode 100644 validation/preprocessor/expand-and-nl.c
diff --git a/pre-process.c b/pre-process.c
index 479c8d225602..2893c3ab65d4 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -306,6 +306,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/expand-and-nl.c b/validation/preprocessor/expand-and-nl.c
new file mode 100644
index 000000000000..06f6ab5cd91b
--- /dev/null
+++ b/validation/preprocessor/expand-and-nl.c
@@ -0,0 +1,14 @@
+#define M(X) X-X
+
+M(a
+b)
+/*
+ * check-name: expand-and-nl
+ * check-command: sparse -E $file
+ * check-known-to-fail
+ *
+ * check-output-start
+
+a b-a b
+ * check-output-end
+ */
--
2.25.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic