blob: 0b4dd2073401b9432f424434af1e75b2fa26453a [file] [log] [blame]
Argyrios Kyrtzidis5c5f03e2011-08-18 19:41:28 +00001struct Point {
2 float x;
3 float y;
4 float z;
5};
6
7#define MACRO2(x) x
8#define MACRO(x) MACRO2(x)
9
10void test(struct Point *p) {
11 p->x;
12 MACRO(p->x);
13}
14
Argyrios Kyrtzidisf1e5b152012-12-21 01:51:12 +000015#define MACRO3(x,y,z) x;y;z
Argyrios Kyrtzidiscd0fd182012-12-21 01:17:20 +000016
Argyrios Kyrtzidisbb06b502012-12-22 04:48:10 +000017void test2(struct Point *p) {
Argyrios Kyrtzidiscd0fd182012-12-21 01:17:20 +000018 MACRO3(p->x);
19 MACRO3(p->x
20}
21
Argyrios Kyrtzidisbb06b502012-12-22 04:48:10 +000022#define VGM(...) 0
23#define VGM2(...) __VA_ARGS__
24
25// These need to be last, to test proper handling of EOF.
26#ifdef EOF_TEST1
27void test3(struct Point *p) {
28 VGM(1,2, p->x
29
30#elif EOF_TEST2
31void test3(struct Point *p) {
32 VGM2(VGM(1,2, p->x
33
34#endif
35
Argyrios Kyrtzidis5c5f03e2011-08-18 19:41:28 +000036// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck %s
37// RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s
Argyrios Kyrtzidiscd0fd182012-12-21 01:17:20 +000038// RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck %s
39// RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck %s
Argyrios Kyrtzidis5c5f03e2011-08-18 19:41:28 +000040// CHECK: FieldDecl:{ResultType float}{TypedText x} (35)
41// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText y} (35)
42// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText z} (35)
43// CHECK-NEXT: Completion contexts:
44// CHECK-NEXT: Arrow member access
45// CHECK-NEXT: Container Kind: StructDecl
Argyrios Kyrtzidisbb06b502012-12-22 04:48:10 +000046
47// With these, code-completion is unknown because the macro argument (and the
48// completion point) is not expanded by the macro definition.
49// RUN: c-index-test -code-completion-at=%s:28:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF
50// RUN: c-index-test -code-completion-at=%s:32:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF
51// CHECK-EOF: Completion contexts:
52// CHECK-EOF: Unknown