aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/preprocessor
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-12-07 23:17:07 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-22 01:38:24 +0200
commitc03ffb3212281d01b304781e67ea6fc38feb224e (patch)
tree25b902785b910205d468f4c622125f0e8256049a /validation/preprocessor
parente140005c44ef962f5ee2a72735ea727e5db7f7f6 (diff)
downloadsparse-dev-c03ffb3212281d01b304781e67ea6fc38feb224e.tar.gz
delay 'empty character constant' warning to phase 5
A subset of C syntax regarding character constants is: char-constant: ' c-char-sequence ' c-char-sequence: char c-char-sequence char In short, when tokenized, a character constant must have at least one character between the quotes. Consequently, sparse will issue an error on empty character constants (unlike GCC). However, sparse issues the error during tokenization (phase 3), before preprocessing directives are handled (phase 4). This means that code like: #if 0 ... '' #endif will throw an error although the corresponding code is discarded. Fix this by 1) silently accept empty char constants during tokenization 2) issue the diagnostic only when escape sequences are handled. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/preprocessor')
-rw-r--r--validation/preprocessor/empty-char-constant.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/validation/preprocessor/empty-char-constant.c b/validation/preprocessor/empty-char-constant.c
new file mode 100644
index 00000000..2c248159
--- /dev/null
+++ b/validation/preprocessor/empty-char-constant.c
@@ -0,0 +1,13 @@
+#if 0
+ ''
+#endif
+
+/*
+ * check-name: empty-char-constant
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */