aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/preprocessor
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-04-16 13:36:27 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-01 17:02:34 +0200
commit2b2944497885313e7b296458092c20f80e2aed2c (patch)
treecedf46fec6439f3709d327cf3539a1ec31b35a2a /validation/preprocessor
parent551b85c8a241bd45b267db152eca4cb01eddce39 (diff)
downloadsparse-dev-2b2944497885313e7b296458092c20f80e2aed2c.tar.gz
do not to ignore old preprocessor testcases
validation/{phase2/backslash,phase3/comments} are two ancient testcases that predate ./test-suite and they are ignored by the testsuite because they do not have a '.c' extension. Change this by: - renaming them with a '.c' extension - moving them to validation/preprocessor/ - adding the testsuite tags & results to them - remove comments about their previous status Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/preprocessor')
-rw-r--r--validation/preprocessor/phase2-backslash.c67
-rw-r--r--validation/preprocessor/phase3-comments.c17
2 files changed, 84 insertions, 0 deletions
diff --git a/validation/preprocessor/phase2-backslash.c b/validation/preprocessor/phase2-backslash.c
new file mode 100644
index 00000000..21d94d7d
--- /dev/null
+++ b/validation/preprocessor/phase2-backslash.c
@@ -0,0 +1,67 @@
+/*
+ * '\\' has a special meaning on phase 2 if and only if it is immediately
+ * followed by '\n'. In any other position it's left alone as any other
+ * character.
+ *
+ * [5.1.1.2(1.2)]:
+ * Each instance of a backslash character (\) immediately followed by
+ * a new-line character is deleted, splicing physical source lines to
+ * form logical source lines. Only the last backslash on any physical
+ * source line shall be eligible for being part of such a splice.
+ * A source file that is not empty shall end in a new-line character,
+ * which shall not be immediately preceded by a backslash character
+ * before any such splicing takes place.
+ *
+ * Note that this happens on the phase 2, before we even think of any
+ * tokens. In other words, splicing is ignorant of and transparent for
+ * the rest of tokenizer.
+ */
+
+/*
+ * check-name: phase2-backslash
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+"\a"
+1
+D
+'\a'
+ * check-output-end
+ *
+ * check-error-start
+preprocessor/phase2-backslash.c:68:0: warning: backslash-newline at end of file
+ * check-error-end
+ */
+
+#define A(x) #x
+#define B(x) A(x)
+/* This should result in "\a" */
+B(\a)
+
+#define C\
+ 1
+/* This should give 1 */
+C
+
+#define D\
+1
+/* And this should give D, since '\n' is removed and we get no whitespace */
+D
+
+#define E '\\
+a'
+/* This should give '\a' - with no warnings issued */
+E
+
+/* This should give nothing */
+// junk \
+more junk
+
+/* This should also give nothing */
+/\
+* comment *\
+/
+
+/* And this should complain since final newline should not be eaten by '\\' */
+\
diff --git a/validation/preprocessor/phase3-comments.c b/validation/preprocessor/phase3-comments.c
new file mode 100644
index 00000000..7106b480
--- /dev/null
+++ b/validation/preprocessor/phase3-comments.c
@@ -0,0 +1,17 @@
+/*
+ * Each comment should be treated as if it had been a single space.
+ */
+
+/* This should give nothing */
+#define X /*
+ */ Y
+
+/*
+ * check-name: phase3-comments
+ * check-command: sparse -E $file
+ *
+ * check-output-start
+
+
+ * check-output-end
+ */