aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>2004-06-14 16:09:02 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:02:07 -0700
commit669244d22464b8e3af138f4df9e1f914f6feeffb (patch)
treee528bf56220f274d8fc5e16b274764812b32f114 /validation
parent87ce1691126e447c34d16abc1624d6ca0e079a4a (diff)
downloadsparse-dev-669244d22464b8e3af138f4df9e1f914f6feeffb.tar.gz
[PATCH] lazy-copy macro expansion in pre-processing
This is almost a total rewrite of the macro expansion. It now does lazy-copy or the arguments, with the realization that if an argument only shows up once in the macro expansion (quite common), we don't need to allocate a new copy of the argument token stream, we can just insert it as-is. I hope it's reasonably clean and readable; review would be obviously welcome.
Diffstat (limited to 'validation')
-rw-r--r--validation/preprocessor12.c7
-rw-r--r--validation/preprocessor13.c7
-rw-r--r--validation/preprocessor14.c7
-rw-r--r--validation/preprocessor15.c7
4 files changed, 28 insertions, 0 deletions
diff --git a/validation/preprocessor12.c b/validation/preprocessor12.c
new file mode 100644
index 00000000..385c1a7d
--- /dev/null
+++ b/validation/preprocessor12.c
@@ -0,0 +1,7 @@
+/*
+ * GNU kludge
+ */
+#define A(x,...) x,##__VA_ARGS__
+A(1)
+A(1,2)
+A(1,2,3)
diff --git a/validation/preprocessor13.c b/validation/preprocessor13.c
new file mode 100644
index 00000000..96c813ee
--- /dev/null
+++ b/validation/preprocessor13.c
@@ -0,0 +1,7 @@
+/*
+ * GNU kludge, corner case
+ */
+#define A(x,...) x##,##__VA_ARGS__
+A(1)
+A(1,2)
+A(1,2,3)
diff --git a/validation/preprocessor14.c b/validation/preprocessor14.c
new file mode 100644
index 00000000..001f1f2d
--- /dev/null
+++ b/validation/preprocessor14.c
@@ -0,0 +1,7 @@
+/*
+ * GNU kludge, another corner case
+ */
+#define A(x,y,...) ,##x##__VA_ARGS__
+A(,1)
+#define B(x,y,...) x##,##__VA_ARGS__
+B(,1)
diff --git a/validation/preprocessor15.c b/validation/preprocessor15.c
new file mode 100644
index 00000000..0a2dfd7f
--- /dev/null
+++ b/validation/preprocessor15.c
@@ -0,0 +1,7 @@
+#define A defi
+#define B ned
+#define C(x,y) x##y
+#define D(x,y) C(x,y)
+#if D(A,B) B
+D(1,2)
+#endif