yum-mirror/slang

Making it easier to work with shaders

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

Theresa FoleyInitial support for variadic macros (#1887)890512510

master
715 B30 linesraw
1// variadic-macro.slang
2//DIAGNOSTIC_TEST:SIMPLE:-E
3
4// First we text a variadic macro with the default variadic
5// parameter name (`__VA_ARGS__`) and other non-variadic parameter.
6
7#define A(X, ...) (X ; __VA_ARGS__)
8
9A(1, 2, 3)
10
11// Next we test a varadic macro where the variadic parameter
12// has been given an explicit name.
13
14#define B(B_ARGS...) (B_ARGS)
15
16B(4, 5)
17
18// Finally, we test the case where the variadic parameter
19// might have zero arguments passed for it, so that
20// the result produces a trailing comma.
21//
22// TODO: If we add support for deleting trailing commas
23// in these cases to Slang, we can update this case to
24// test that support.
25
26#define C(Y, ARGS...) (Y , ARGS)
27
28C(1)
29C(2, 3)
30C(4, 5, 6)