Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame^] | 1 | // Example from C99 6.10.3.4p6 |
| 2 | |
| 3 | // RUN: clang -E %s | grep -F 'printf("x" "1" "= %d, x" "2" "= s" x1, x2);' && |
| 4 | // RUN: clang -E %s | grep 'fputs("strncmp(\\"abc\\\\0d\\" \\"abc\\", .\\\\4.) == 0" ": @\\n", s);' && |
| 5 | // RUN: clang -E %s | grep -F 'include "vers2.h"' && |
| 6 | // RUN: clang -E %s | grep -F '"hello";' && |
| 7 | // RUN: clang -E %s | grep -F '"hello" ", world"' |
| 8 | |
| 9 | #define str(s) # s |
| 10 | #define xstr(s) str(s) |
| 11 | #define debug(s, t) printf("x" # s "= %d, x" # t "= s" \ |
| 12 | x ## s, x ## t) |
| 13 | #define INCFILE(n) vers ## n |
| 14 | #define glue(a, b) a ## b |
| 15 | #define xglue(a, b) glue(a, b) |
| 16 | #define HIGHLOW "hello" |
| 17 | #define LOW LOW ", world" |
| 18 | debug(1, 2); |
| 19 | fputs(str(strncmp("abc\0d" "abc", '\4') // this goes away |
| 20 | == 0) str(: @\n), s); |
| 21 | include xstr(INCFILE(2).h) |
| 22 | glue(HIGH, LOW); |
| 23 | xglue(HIGH, LOW) |
| 24 | |