blob: 670b13f6344b5d3498b17a73d71597d4b7b5aa19 [file] [log] [blame]
Douglas Gregor3ac73852009-11-09 16:04:45 +00001// Code-completion through the C interface
Douglas Gregorac06a7c2009-11-09 16:06:30 +00002#include "nonexistent_header.h"
Douglas Gregor3ac73852009-11-09 16:04:45 +00003struct X {
4 int member;
Douglas Gregorff4393c2009-11-09 21:35:27 +00005
6 enum E { Val1 };
Douglas Gregor3ac73852009-11-09 16:04:45 +00007};
8
9struct Y {
10 float member;
11 void memfunc(int i = 17);
12};
13
14struct Z : X, Y {
15 double member;
16 operator int() const;
17};
18
19struct Z get_Z();
20
21void test_Z() {
Douglas Gregorff4393c2009-11-09 21:35:27 +000022 // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
Douglas Gregor3ac73852009-11-09 16:04:45 +000023 get_Z().member = 17;
24}
25
26
27float& overloaded(int i, long second);
28double& overloaded(float f, int second);
29int& overloaded(Z z, int second);
30
31void test_overloaded() {
Douglas Gregorff4393c2009-11-09 21:35:27 +000032 // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
Douglas Gregor3ac73852009-11-09 16:04:45 +000033 overloaded(Z(), 0);
34}
35
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000036// CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000037// CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
38// CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
Douglas Gregorab0b4f12010-01-13 23:24:38 +000039// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
40// CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const}
John McCall7c2342d2010-03-10 11:27:22 +000041// CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )}
42// CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )}
43// CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )}
44// CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
Douglas Gregor76282942009-12-11 17:31:05 +000045// CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
46// CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
47// CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
Douglas Gregorab0b4f12010-01-13 23:24:38 +000048// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
49// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
50// CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
Douglas Gregor3ac73852009-11-09 16:04:45 +000051
John McCall7c2342d2010-03-10 11:27:22 +000052// CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000053// CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
54// CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}