yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

T. FoleyFix a bug in preprocessor "busy" logic (#1875)58d7af37f

master
586 B20 linesraw
1// pp-bug-1.slang
2//DIAGNOSTIC_TEST:SIMPLE:-E
3
4// The bug in this case was related to a use-after-free
5// where the list of "busy" macros for a function-like
6// macro invocation was being set based on what was
7// busy when reading the macro name, which could include
8// streams that had been popped by the time arguments
9// had been read.
10
11#define NUM_CASES 2
12#define X1(M) M(0)
13#define X2(M) M(0) M(1)
14#define CONCAT2(a, b) a##b
15#define CONCAT(a, b) CONCAT2(a, b)
16#define FOREACH(M) CONCAT(X, NUM_CASES)(M)
17#define CASE(i) i
18// Should output: 0 1
19// Outputs: 0 CASE ( 1 )
20FOREACH(CASE)