Richard Trieu | ecd36ee | 2015-08-12 18:24:59 +0000 | [diff] [blame] | 1 | // RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s -strict-whitespace |
| 2 | |
| 3 | #define NO_INITIATION(x) int a = x * 2 |
| 4 | #define NO_DEFINITION(x) int c = x * 2 |
| 5 | |
| 6 | NO_INITIATION(a); |
| 7 | NO_DEFINITION(b); |
| 8 | |
| 9 | // CHECK: {{.*}}:6:15: warning: variable 'a' is uninitialized when used within its own initialization |
| 10 | // CHECK-NEXT: NO_INITIATION(a); |
| 11 | // CHECK-NEXT: ~~~~~~~~~~~~~~^~ |
| 12 | // CHECK-NEXT: {{.*}}:3:34: note: expanded from macro 'NO_INITIATION' |
| 13 | // CHECK-NEXT: #define NO_INITIATION(x) int a = x * 2 |
Richard Trieu | c309624 | 2015-09-24 01:21:01 +0000 | [diff] [blame] | 14 | // CHECK-NEXT: ~ ^ |
Richard Trieu | ecd36ee | 2015-08-12 18:24:59 +0000 | [diff] [blame] | 15 | |
| 16 | // CHECK: {{.*}}:7:15: error: use of undeclared identifier 'b' |
| 17 | // CHECK-NEXT: NO_DEFINITION(b); |
| 18 | // CHECK-NEXT: ^ |
| 19 | |
| 20 | |
| 21 | #define F(x) x + 1 |
| 22 | #define ADD(x,y) y + F(x) |
| 23 | #define SWAP_ARGU(x,y) ADD(y,x) |
| 24 | |
| 25 | int p = SWAP_ARGU(3, x); |
| 26 | |
| 27 | // CHECK: {{.*}}:25:23: error: use of undeclared identifier 'x' |
| 28 | // CHECK-NEXT: int p = SWAP_ARGU(3, x); |
| 29 | // CHECK-NEXT: ^ |
Richard Trieu | c309624 | 2015-09-24 01:21:01 +0000 | [diff] [blame] | 30 | |
| 31 | #define APPLY(f,x,y) x f y |
| 32 | |
| 33 | struct node { |
| 34 | }; |
| 35 | |
| 36 | node ff; |
| 37 | |
| 38 | int r = APPLY(+,ff,1); |
| 39 | // CHECK: {{.*}}:38:15: error: invalid operands to binary expression ('node' and 'int') |
| 40 | // CHECK-NEXT: int r = APPLY(+,ff,1); |
| 41 | // CHECK-NEXT: ^ ~~ ~ |
| 42 | // CHECK-NEXT: {{.*}}:31:24: note: expanded from macro 'APPLY' |
| 43 | // CHECK-NEXT: #define APPLY(f,x,y) x f y |
| 44 | // CHECK-NEXT: ~ ^ ~ |