aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLinus Torvalds <torvalds@home.osdl.org>2003-07-17 23:28:03 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:56 -0700
commit10e9653b49d81800837f1e7c8ea39039cb32a27f (patch)
treebcdb20c427ad8e97810d2623cea5f86b60c3820b /validation
parent8d121d51b6f88e90d166af84d098c6e3af066a87 (diff)
downloadsparse-dev-10e9653b49d81800837f1e7c8ea39039cb32a27f.tar.gz
Add two preprocessor test-cases from comp.std.c.
We actually pass one of them, surprise surprise. I should add a few more that highlight the known problems in token pasting etc, but I'm lazy. The C preprocessor is a bitch.
Diffstat (limited to 'validation')
-rw-r--r--validation/preprocessor1.c14
-rw-r--r--validation/preprocessor2.c15
2 files changed, 29 insertions, 0 deletions
diff --git a/validation/preprocessor1.c b/validation/preprocessor1.c
new file mode 100644
index 00000000..5ae20aab
--- /dev/null
+++ b/validation/preprocessor1.c
@@ -0,0 +1,14 @@
+/*
+ * This makes us really hurl chunks, causing
+ * infinite recursion until we run out of stack.
+ *
+ * It _should_ result in just a single plain
+ *
+ * "foo"
+ *
+ * (without the quotes).
+ */
+#define func(x) x
+#define bar func(
+#define foo bar foo
+foo )
diff --git a/validation/preprocessor2.c b/validation/preprocessor2.c
new file mode 100644
index 00000000..340938ee
--- /dev/null
+++ b/validation/preprocessor2.c
@@ -0,0 +1,15 @@
+/*
+ * This one we happen to get right.
+ *
+ * It should result in a simple
+ *
+ * a + b
+ *
+ * for a proper preprocessor.
+ */
+#define TWO a, b
+
+#define UNARY(x) BINARY(x)
+#define BINARY(x, y) x + y
+
+UNARY(TWO)