summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-17 13:33:10 -0700
committerCarl Worth <cworth@cworth.org>2010-05-18 22:09:57 -0700
commitd476db38fe21f5e6061a7d93dbd5a9991b91bf59 (patch)
treebb77eac27e979f53781ffe8318bc38192f7af608 /tests
parent1a29500e72ac338c1fb243742aff1c167e1059db (diff)
Add several tests where the defined value of a macro is (or looks like) a macro
Many of these look quite similar to existing tests that are handled correctly, yet none of these work. For example, in test 30 we have a simple non-function macro "foo" that is defined as "bar(baz(success))" and obviously non-function macro expansion has been working for a long time. Similarly, if we had text of "bar(baz(success))" it would be expanded correctly as well. But when this otherwise functioning text appears as the body of a macro, things don't work at all. This is pointing out a fundamental problem with the current approach. The current code does a recursive expansion of a macro definition, but this doesn't involve the parsing machinery, so it can't actually handle things like an arbitrary nesting of parentheses. The fix will require the parser to stuff macro values back into the lexer to get at all of the existing machinery when expanding macros.
Diffstat (limited to 'tests')
-rw-r--r--tests/027-define-chain-obj-to-func.c3
-rw-r--r--tests/028-define-chain-obj-to-non-func.c3
-rw-r--r--tests/029-define-chain-obj-to-func-with-args.c3
-rw-r--r--tests/030-define-chain-obj-to-func-compose.c4
-rw-r--r--tests/031-define-chain-func-to-func-compose.c4
5 files changed, 17 insertions, 0 deletions
diff --git a/tests/027-define-chain-obj-to-func.c b/tests/027-define-chain-obj-to-func.c
new file mode 100644
index 0000000..5ccb52c
--- /dev/null
+++ b/tests/027-define-chain-obj-to-func.c
@@ -0,0 +1,3 @@
+#define failure() success
+#define foo failure()
+foo
diff --git a/tests/028-define-chain-obj-to-non-func.c b/tests/028-define-chain-obj-to-non-func.c
new file mode 100644
index 0000000..44962a7
--- /dev/null
+++ b/tests/028-define-chain-obj-to-non-func.c
@@ -0,0 +1,3 @@
+#define success() failure
+#define foo success
+foo
diff --git a/tests/029-define-chain-obj-to-func-with-args.c b/tests/029-define-chain-obj-to-func-with-args.c
new file mode 100644
index 0000000..261f7d2
--- /dev/null
+++ b/tests/029-define-chain-obj-to-func-with-args.c
@@ -0,0 +1,3 @@
+#define bar(failure) failure
+#define foo bar(success)
+foo
diff --git a/tests/030-define-chain-obj-to-func-compose.c b/tests/030-define-chain-obj-to-func-compose.c
new file mode 100644
index 0000000..e56fbef
--- /dev/null
+++ b/tests/030-define-chain-obj-to-func-compose.c
@@ -0,0 +1,4 @@
+#define baz(failure) failure
+#define bar(failure) failure
+#define foo bar(baz(success))
+foo
diff --git a/tests/031-define-chain-func-to-func-compose.c b/tests/031-define-chain-func-to-func-compose.c
new file mode 100644
index 0000000..3f4c874
--- /dev/null
+++ b/tests/031-define-chain-func-to-func-compose.c
@@ -0,0 +1,4 @@
+#define baz(failure) failure
+#define bar(failure) failure
+#define foo() bar(baz(success))
+foo()