preliminary patch to fix http://lists.nongnu.org/archive/html/tinycc-devel/2015-04...
[tinycc.git] / tests / tests2 / 80_macros.c
blob20c7f4b99b6c8329592885040cc7513bb6f7d65e
1 #include <stdio.h>
3 #define A(a,b...) g(a,##b,##b)
4 #define B(x...) x
5 #define C \
7 #define D(x,y) x ## y
8 #define E(x,y,z) x ## y ## z
9 #define F(x) x
10 #define G C
12 #define STRINGIFY2(x) #x
13 #define STRINGIFY(x) STRINGIFY2(x)
15 int main(void)
17 printf("%s\n", STRINGIFY()); // should produce the empty string
18 printf("%s\n", STRINGIFY(C)); // should produce the empty string
19 printf("%s\n", STRINGIFY(
20 A(a,)
21 A(a,b)
22 A(a,b,c)
23 )); // should produce g(a ) g(a,b,b)g(a,b,c,b,c)
24 printf("%s\n", STRINGIFY(B())); // should produce the empty string
25 printf("%s\n", STRINGIFY(B(C))); // should produce the empty string
26 printf("%s\n", STRINGIFY(D(,))); // should produce the empty string
27 printf("%s\n", STRINGIFY(E(1,,))); // should produce 1
28 printf("%s\n", STRINGIFY(E(,2,))); // should produce 2
29 printf("%s\n", STRINGIFY(E(,,3))); // should produce 3
30 printf("%s\n", STRINGIFY(E(1,2,3))); // should produce 123
32 // should produce g(a ) g(a )g(a )g(a )g(a )
33 printf("%s\n", STRINGIFY(A(a,F()) A(a,C) A(a,G) A(a,) A(a)));
35 return 0;