aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorgrischka <grischka>2017-06-05 13:21:39 +0200
committergrischka <grischka>2017-07-09 11:46:14 +0200
commit6c468c10f70d74e962591a0584765e42ce1bcaf2 (patch)
tree2d56ee0017b4b95afdd1bd47b8f2c8131ed06418 /tests
parent824dcebe59f52a686b003214c1af0633cf5fe89e (diff)
downloadtinycc-6c468c10f70d74e962591a0584765e42ce1bcaf2.tar.gz
tinycc-6c468c10f70d74e962591a0584765e42ce1bcaf2.tar.bz2
tccpp: allow "#define X defined Y ..."
That means: we do not macro-expand the argument of 'defined' Also: store the last token position into the TokenString structure in order to get rid of the tok_last function.
Diffstat (limited to 'tests')
-rw-r--r--tests/pp/21.c36
-rw-r--r--tests/pp/21.expect8
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/pp/21.c b/tests/pp/21.c
new file mode 100644
index 0000000..1316226
--- /dev/null
+++ b/tests/pp/21.c
@@ -0,0 +1,36 @@
+/* accept 'defined' as result of substitution */
+
+----- 1 ------
+#define AAA 2
+#define BBB
+#define CCC (defined ( AAA ) && AAA > 1 && !defined BBB)
+#if !CCC
+OK
+#else
+NOT OK
+#endif
+
+----- 2 ------
+#undef BBB
+#if CCC
+OK
+#else
+NOT OK
+#endif
+
+----- 3 ------
+#define DEFINED defined
+#define DDD (DEFINED ( AAA ) && AAA > 1 && !DEFINED BBB)
+#if (DDD)
+OK
+#else
+NOT OK
+#endif
+
+----- 4 ------
+#undef AAA
+#if !(DDD)
+OK
+#else
+NOT OK
+#endif
diff --git a/tests/pp/21.expect b/tests/pp/21.expect
new file mode 100644
index 0000000..5a1376b
--- /dev/null
+++ b/tests/pp/21.expect
@@ -0,0 +1,8 @@
+----- 1 ------
+OK
+----- 2 ------
+OK
+----- 3 ------
+OK
+----- 4 ------
+OK