summaryrefslogtreecommitdiffstats
path: root/tests/preprocessor/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/preprocessor/bugs')
-rw-r--r--tests/preprocessor/bugs/pp-bug-1.slang20
-rw-r--r--tests/preprocessor/bugs/pp-bug-1.slang.expected6
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/preprocessor/bugs/pp-bug-1.slang b/tests/preprocessor/bugs/pp-bug-1.slang
new file mode 100644
index 000000000..b0f026a6b
--- /dev/null
+++ b/tests/preprocessor/bugs/pp-bug-1.slang
@@ -0,0 +1,20 @@
+// pp-bug-1.slang
+//DIAGNOSTIC_TEST:SIMPLE:-E
+
+// The bug in this case was related to a use-after-free
+// where the list of "busy" macros for a function-like
+// macro invocation was being set based on what was
+// busy when reading the macro name, which could include
+// streams that had been popped by the time arguments
+// had been read.
+
+#define NUM_CASES 2
+#define X1(M) M(0)
+#define X2(M) M(0) M(1)
+#define CONCAT2(a, b) a##b
+#define CONCAT(a, b) CONCAT2(a, b)
+#define FOREACH(M) CONCAT(X, NUM_CASES)(M)
+#define CASE(i) i
+// Should output: 0 1
+// Outputs: 0 CASE ( 1 )
+FOREACH(CASE) \ No newline at end of file
diff --git a/tests/preprocessor/bugs/pp-bug-1.slang.expected b/tests/preprocessor/bugs/pp-bug-1.slang.expected
new file mode 100644
index 000000000..522fc1b40
--- /dev/null
+++ b/tests/preprocessor/bugs/pp-bug-1.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+0 1
+}