Chris Lattner | 9944f78 | 2009-12-07 01:49:36 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -E -dM %s -o - | FileCheck %s -strict-whitespace |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 2 | |
Chris Lattner | 9944f78 | 2009-12-07 01:49:36 +0000 | [diff] [blame] | 3 | // Space at end even without expansion tokens |
Daniel Dunbar | a498ca6 | 2009-12-09 00:04:46 +0000 | [diff] [blame^] | 4 | // CHECK: #define A(x) |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 5 | #define A(x) |
| 6 | |
| 7 | // Space before expansion list. |
Daniel Dunbar | a498ca6 | 2009-12-09 00:04:46 +0000 | [diff] [blame^] | 8 | // CHECK: #define B(x,y) x y |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 9 | #define B(x,y)x y |
| 10 | |
Chris Lattner | 9944f78 | 2009-12-07 01:49:36 +0000 | [diff] [blame] | 11 | // No space in argument list. |
| 12 | // CHECK: #define C(x,y) x y |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 13 | #define C(x, y) x y |
| 14 | |
| 15 | // No paste avoidance. |
Chris Lattner | 5146b1b | 2009-12-07 01:57:13 +0000 | [diff] [blame] | 16 | // CHECK: #define D() .. |
| 17 | #define D() .. |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 18 | |
| 19 | // Simple test. |
Chris Lattner | 5146b1b | 2009-12-07 01:57:13 +0000 | [diff] [blame] | 20 | // CHECK: #define E . |
| 21 | // CHECK: #define F X()Y |
| 22 | #define E . |
| 23 | #define F X()Y |
Chris Lattner | f73903a | 2009-02-06 06:45:26 +0000 | [diff] [blame] | 24 | |
| 25 | // gcc prints macros at end of translation unit, so last one wins. |
Chris Lattner | 5146b1b | 2009-12-07 01:57:13 +0000 | [diff] [blame] | 26 | // CHECK: #define G 2 |
| 27 | #define G 1 |
| 28 | #undef G |
| 29 | #define G 2 |
Chris Lattner | 807b93e | 2009-12-07 01:58:34 +0000 | [diff] [blame] | 30 | |
| 31 | // Variadic macros of various sorts. PR5699 |
| 32 | |
| 33 | // CHECK: H(x,...) __VA_ARGS__ |
| 34 | #define H(x, ...) __VA_ARGS__ |
| 35 | // CHECK: I(...) __VA_ARGS__ |
| 36 | #define I(...) __VA_ARGS__ |
| 37 | // CHECK: J(x...) __VA_ARGS__ |
| 38 | #define J(x ...) __VA_ARGS__ |