1 // Code-completion through the C interface
2 #include "nonexistent_header.h"
3 struct X {
4   int member;
5 
6   enum E { Val1 };
7 };
8 
9 struct Y {
10   float member;
11   void memfunc(int i = 17);
12 };
13 
14 struct Z : X, Y {
15   double member;
16   operator int() const;
17 };
18 struct W { };
19 struct Z get_Z();
20 namespace N { }
21 void test_Z() {
22   // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
23   get_Z().member = 17;
24 }
25 
26 
27 float& overloaded(int i, long second);
28 double& overloaded(float f, int second);
29 int& overloaded(Z z, int second);
30 
31 void test_overloaded() {
32   // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
33   overloaded(Z(), 0);
34 }
35 
36 Z::operator int() const {
37   return 0;
38 }
39 
40 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
41 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
42 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
43 // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
44 // CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative  const}
45 // CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )}
46 // CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )}
47 // CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )}
48 // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
49 // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
50 // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
51 // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
52 // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
53 // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
54 // CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
55 
56 // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
57 // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
58 // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
59 
60 // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
61 // CHECK-EXPR: NotImplemented:{TypedText int} (65)
62 // CHECK-EXPR: NotImplemented:{TypedText long} (65)
63 // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5)
64 // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10)
65 // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11)
66 // CHECK-EXPR: FunctionDecl:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22)
67 // CHECK-EXPR: NotImplemented:{TypedText N}{Text ::} (75)
68