Argyrios Kyrtzidis | 5c5f03e | 2011-08-18 19:41:28 +0000 | [diff] [blame] | 1 | struct Point { |
| 2 | float x; |
| 3 | float y; |
| 4 | float z; |
| 5 | }; |
| 6 | |
| 7 | #define MACRO2(x) x |
| 8 | #define MACRO(x) MACRO2(x) |
| 9 | |
| 10 | void test(struct Point *p) { |
| 11 | p->x; |
| 12 | MACRO(p->x); |
| 13 | } |
| 14 | |
Argyrios Kyrtzidis | f1e5b15 | 2012-12-21 01:51:12 +0000 | [diff] [blame] | 15 | #define MACRO3(x,y,z) x;y;z |
Argyrios Kyrtzidis | cd0fd18 | 2012-12-21 01:17:20 +0000 | [diff] [blame] | 16 | |
Argyrios Kyrtzidis | bb06b50 | 2012-12-22 04:48:10 +0000 | [diff] [blame] | 17 | void test2(struct Point *p) { |
Argyrios Kyrtzidis | cd0fd18 | 2012-12-21 01:17:20 +0000 | [diff] [blame] | 18 | MACRO3(p->x); |
| 19 | MACRO3(p->x |
| 20 | } |
| 21 | |
Argyrios Kyrtzidis | fdf5706 | 2013-02-22 22:28:58 +0000 | [diff] [blame^] | 22 | #define FM(x) x |
| 23 | void test3(struct Point *p) { |
| 24 | FM(p->x, a); |
| 25 | } |
| 26 | |
Argyrios Kyrtzidis | bb06b50 | 2012-12-22 04:48:10 +0000 | [diff] [blame] | 27 | #define VGM(...) 0 |
| 28 | #define VGM2(...) __VA_ARGS__ |
| 29 | |
| 30 | // These need to be last, to test proper handling of EOF. |
| 31 | #ifdef EOF_TEST1 |
| 32 | void test3(struct Point *p) { |
| 33 | VGM(1,2, p->x |
| 34 | |
| 35 | #elif EOF_TEST2 |
| 36 | void test3(struct Point *p) { |
| 37 | VGM2(VGM(1,2, p->x |
| 38 | |
| 39 | #endif |
| 40 | |
Argyrios Kyrtzidis | 5c5f03e | 2011-08-18 19:41:28 +0000 | [diff] [blame] | 41 | // RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck %s |
| 42 | // RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s |
Argyrios Kyrtzidis | cd0fd18 | 2012-12-21 01:17:20 +0000 | [diff] [blame] | 43 | // RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck %s |
| 44 | // RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck %s |
Argyrios Kyrtzidis | fdf5706 | 2013-02-22 22:28:58 +0000 | [diff] [blame^] | 45 | // RUN: c-index-test -code-completion-at=%s:24:9 %s | FileCheck %s |
Argyrios Kyrtzidis | 5c5f03e | 2011-08-18 19:41:28 +0000 | [diff] [blame] | 46 | // CHECK: FieldDecl:{ResultType float}{TypedText x} (35) |
| 47 | // CHECK-NEXT: FieldDecl:{ResultType float}{TypedText y} (35) |
| 48 | // CHECK-NEXT: FieldDecl:{ResultType float}{TypedText z} (35) |
| 49 | // CHECK-NEXT: Completion contexts: |
| 50 | // CHECK-NEXT: Arrow member access |
| 51 | // CHECK-NEXT: Container Kind: StructDecl |
Argyrios Kyrtzidis | bb06b50 | 2012-12-22 04:48:10 +0000 | [diff] [blame] | 52 | |
| 53 | // With these, code-completion is unknown because the macro argument (and the |
| 54 | // completion point) is not expanded by the macro definition. |
Argyrios Kyrtzidis | fdf5706 | 2013-02-22 22:28:58 +0000 | [diff] [blame^] | 55 | // RUN: c-index-test -code-completion-at=%s:33:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF |
| 56 | // RUN: c-index-test -code-completion-at=%s:37:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF |
Argyrios Kyrtzidis | bb06b50 | 2012-12-22 04:48:10 +0000 | [diff] [blame] | 57 | // CHECK-EOF: Completion contexts: |
| 58 | // CHECK-EOF: Unknown |