diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-04-13 18:26:20 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 18:26:20 -0400 |
| commit | 36b8217fcb4b8ea4566470635f492331171da7f3 (patch) | |
| tree | fa77c560bcfc6f6b1d08dd33f7b32be20215a463 /tests | |
| parent | 5a0d62f302b38e972c99cb5e228d016b5fa041ff (diff) | |
More preprocessor issues including an infinite loop (#1791)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Tests showing issues with preprocessor behavior.
* Fix comment/typo.
* Infinite loop.
* Another preproc bug.
* Small fixes in preproc test
* Bug around empty single parameter
* Repeated parameter name.
* Fix comment.
* #undef of undefined macro is not an error.
* Clarify that it is a warning on Slang.
* Fix expected diagnostic.
* Fix preproc-detail-2.slang.expected
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/current-bugs/preproc-concat-4.slang | 9 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-concat-5.slang | 13 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-1.slang | 12 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-1.slang.expected | 7 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-2.slang | 10 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-2.slang.expected | 6 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-3.slang | 9 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-detail-3.slang.expected | 9 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-expand-1.slang | 16 | ||||
| -rw-r--r-- | tests/current-bugs/preproc-expand-1.slang.expected | 6 |
10 files changed, 89 insertions, 8 deletions
diff --git a/tests/current-bugs/preproc-concat-4.slang b/tests/current-bugs/preproc-concat-4.slang index 47b0e1452..31ec16268 100644 --- a/tests/current-bugs/preproc-concat-4.slang +++ b/tests/current-bugs/preproc-concat-4.slang @@ -2,13 +2,6 @@ // NOTE! This test should *fail*, if preprocessor is working correctly! -// So the real question here is what happens with pasting and stringifying. -// As per the spec they have to be performed *before* expansion. If when we do an expansion -// we add to the stream FunctionArg that holds the 'to be' lazily expanded parameter we have a problem -// -// If we move to a new stream *and* the token afterwards, is ## - - #define CONCAT(a, b) a ## b #define A a @@ -21,7 +14,7 @@ // Should be // CONCAT(a, b) A2B2 CONCAT(a, b) -// CONCAT is disabled, A2 and B2 are processed on next pass +// CONCAT is disabled, A and B are expanded on next pass // A2 B2 are first and last tokens pre expansion args // // Slang outputs diff --git a/tests/current-bugs/preproc-concat-5.slang b/tests/current-bugs/preproc-concat-5.slang new file mode 100644 index 000000000..2be554f89 --- /dev/null +++ b/tests/current-bugs/preproc-concat-5.slang @@ -0,0 +1,13 @@ +//DISABLE_DIAGNOSTIC_TEST:SIMPLE:-E + +// NOTE! This test should *fail*, if preprocessor is working correctly! + +// It should produce 'THING', as the original invocation should have disabled THING, +// but it actually ends up in an infinite loop. + +#define CONCAT(x, y) x ## y + +#define THING2 THING +#define THING CONCAT(THING, 2) + +THING diff --git a/tests/current-bugs/preproc-detail-1.slang b/tests/current-bugs/preproc-detail-1.slang new file mode 100644 index 000000000..4cff0d205 --- /dev/null +++ b/tests/current-bugs/preproc-detail-1.slang @@ -0,0 +1,12 @@ +//DIAGNOSTIC_TEST:SIMPLE:-E + +// NOTE! This test should *fail*, if preprocessor is working correctly! + +// If a macro can take a single parameter, it is valid to pass in 'nothing'. +// Slang outputs an error about the wrong amount of parameters +// Correct output: a b + +#define A(x) a x b + +A() + diff --git a/tests/current-bugs/preproc-detail-1.slang.expected b/tests/current-bugs/preproc-detail-1.slang.expected new file mode 100644 index 000000000..ba93983af --- /dev/null +++ b/tests/current-bugs/preproc-detail-1.slang.expected @@ -0,0 +1,7 @@ +result code = 0 +standard error = { +tests/current-bugs/preproc-detail-1.slang(10): error 15501: wrong number of arguments to macro (expected 1, got 0) +} +standard output = { + +} diff --git a/tests/current-bugs/preproc-detail-2.slang b/tests/current-bugs/preproc-detail-2.slang new file mode 100644 index 000000000..eb687db31 --- /dev/null +++ b/tests/current-bugs/preproc-detail-2.slang @@ -0,0 +1,10 @@ +//DIAGNOSTIC_TEST:SIMPLE:-E + +// NOTE! This test should *fail*, if preprocessor is working correctly! + +// Macro parameters must have unique names + +#define A(x, x) a x b x c + +A(,) + diff --git a/tests/current-bugs/preproc-detail-2.slang.expected b/tests/current-bugs/preproc-detail-2.slang.expected new file mode 100644 index 000000000..b48d7909f --- /dev/null +++ b/tests/current-bugs/preproc-detail-2.slang.expected @@ -0,0 +1,6 @@ +result code = 0 +standard error = { +} +standard output = { +a b c +} diff --git a/tests/current-bugs/preproc-detail-3.slang b/tests/current-bugs/preproc-detail-3.slang new file mode 100644 index 000000000..b0675204b --- /dev/null +++ b/tests/current-bugs/preproc-detail-3.slang @@ -0,0 +1,9 @@ +//DIAGNOSTIC_TEST:SIMPLE:-E + +// NOTE! This test should *fail*, if preprocessor is working correctly! + +// Undefining a macro that is not defined within C/C++ is defined as *not* an error or a warning. +// On checking with DXC/FXC they also have this behavior (ie they don't output anything) +// It's arguable if Slang should match this behavior - at least it is a warning. + +#undef C
\ No newline at end of file diff --git a/tests/current-bugs/preproc-detail-3.slang.expected b/tests/current-bugs/preproc-detail-3.slang.expected new file mode 100644 index 000000000..a44c60220 --- /dev/null +++ b/tests/current-bugs/preproc-detail-3.slang.expected @@ -0,0 +1,9 @@ +result code = 0 +standard error = { +tests/current-bugs/preproc-detail-3.slang(9): warning 15401: macro 'C' is not defined +#undef C + ^ +} +standard output = { + +} diff --git a/tests/current-bugs/preproc-expand-1.slang b/tests/current-bugs/preproc-expand-1.slang new file mode 100644 index 000000000..f95b432e2 --- /dev/null +++ b/tests/current-bugs/preproc-expand-1.slang @@ -0,0 +1,16 @@ +//DIAGNOSTIC_TEST:SIMPLE:-E + +// NOTE! This test should *fail*, if preprocessor is working correctly! + +// Should produce: Hi +// Slang produces: C ( Hi ) + +#define OPEN ( +#define CLOSE ) + +#define C(x) x + +#define B(x) x + +B(C OPEN Hi CLOSE) + diff --git a/tests/current-bugs/preproc-expand-1.slang.expected b/tests/current-bugs/preproc-expand-1.slang.expected new file mode 100644 index 000000000..d46fa1159 --- /dev/null +++ b/tests/current-bugs/preproc-expand-1.slang.expected @@ -0,0 +1,6 @@ +result code = 0 +standard error = { +} +standard output = { +C ( Hi ) +} |
