1f4a2713aSLionel Sambuc struct bonk { };
test(bonk X)2f4a2713aSLionel Sambuc void test(bonk X) {
3f4a2713aSLionel Sambuc X = X;
4f4a2713aSLionel Sambuc __is_base_of(bonk, bonk);
5f4a2713aSLionel Sambuc }
6f4a2713aSLionel Sambuc
7f4a2713aSLionel Sambuc struct X {
8f4a2713aSLionel Sambuc X operator++();
9f4a2713aSLionel Sambuc X operator++(int);
10f4a2713aSLionel Sambuc };
test2(X x)11f4a2713aSLionel Sambuc void test2(X x) {
12f4a2713aSLionel Sambuc ++(x);
13f4a2713aSLionel Sambuc (x)++;
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc struct S1 { void f(); };
17f4a2713aSLionel Sambuc struct S2 { S1 *operator->(); };
test3(S2 s2)18f4a2713aSLionel Sambuc void test3(S2 s2) {
19f4a2713aSLionel Sambuc s2->f();
20f4a2713aSLionel Sambuc X foo;
21f4a2713aSLionel Sambuc }
22f4a2713aSLionel Sambuc
23f4a2713aSLionel Sambuc template <bool (*tfn)(X*)>
24f4a2713aSLionel Sambuc struct TS {
25f4a2713aSLionel Sambuc void foo();
26f4a2713aSLionel Sambuc };
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc template <bool (*tfn)(X*)>
foo()29f4a2713aSLionel Sambuc void TS<tfn>::foo() {}
30f4a2713aSLionel Sambuc
test4()31*0a6a1f1dSLionel Sambuc void test4() {
32*0a6a1f1dSLionel Sambuc if (int p = 0)
33*0a6a1f1dSLionel Sambuc return;
34*0a6a1f1dSLionel Sambuc }
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambuc class C {
37*0a6a1f1dSLionel Sambuc ~C();
38*0a6a1f1dSLionel Sambuc };
39*0a6a1f1dSLionel Sambuc
40*0a6a1f1dSLionel Sambuc // RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s -fno-delayed-template-parsing | FileCheck %s
41f4a2713aSLionel Sambuc // CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
42f4a2713aSLionel Sambuc // CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
43f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
44f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition)
45f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [1:16 - 1:17]
46f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition)
47f4a2713aSLionel Sambuc // CHECK: Identifier: "test" [2:6 - 2:10] FunctionDecl=test:2:6 (Definition)
48f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [2:10 - 2:11] FunctionDecl=test:2:6 (Definition)
49f4a2713aSLionel Sambuc // CHECK: Identifier: "bonk" [2:11 - 2:15] TypeRef=struct bonk:1:8
50f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [2:16 - 2:17] ParmDecl=X:2:16 (Definition)
51f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [2:17 - 2:18] FunctionDecl=test:2:6 (Definition)
52f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [2:19 - 2:20] CompoundStmt=
53f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [3:5 - 3:6] DeclRefExpr=X:2:16
54f4a2713aSLionel Sambuc // CHECK: Punctuation: "=" [3:7 - 3:8] DeclRefExpr=operator=:1:8
55f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [3:9 - 3:10] DeclRefExpr=X:2:16
56f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [3:10 - 3:11] CompoundStmt=
57f4a2713aSLionel Sambuc // CHECK: Keyword: "__is_base_of" [4:5 - 4:17] UnexposedExpr=
58f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [4:17 - 4:18] UnexposedExpr=
59f4a2713aSLionel Sambuc // CHECK: Identifier: "bonk" [4:18 - 4:22] TypeRef=struct bonk:1:8
60f4a2713aSLionel Sambuc // CHECK: Punctuation: "," [4:22 - 4:23] UnexposedExpr=
61f4a2713aSLionel Sambuc // CHECK: Identifier: "bonk" [4:24 - 4:28] TypeRef=struct bonk:1:8
62f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [4:28 - 4:29] UnexposedExpr=
63f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [4:29 - 4:30] CompoundStmt=
64f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [5:1 - 5:2] CompoundStmt=
65f4a2713aSLionel Sambuc // CHECK: Keyword: "struct" [7:1 - 7:7] StructDecl=X:7:8 (Definition)
66f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [7:8 - 7:9] StructDecl=X:7:8 (Definition)
67f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [7:10 - 7:11] StructDecl=X:7:8 (Definition)
68f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [8:3 - 8:4] TypeRef=struct X:7:8
69f4a2713aSLionel Sambuc // CHECK: Keyword: "operator" [8:5 - 8:13] CXXMethod=operator++:8:5
70f4a2713aSLionel Sambuc // CHECK: Punctuation: "++" [8:13 - 8:15] CXXMethod=operator++:8:5
71f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [8:15 - 8:16] CXXMethod=operator++:8:5
72f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [8:16 - 8:17] CXXMethod=operator++:8:5
73f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [8:17 - 8:18] StructDecl=X:7:8 (Definition)
74f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [9:3 - 9:4] TypeRef=struct X:7:8
75f4a2713aSLionel Sambuc // CHECK: Keyword: "operator" [9:5 - 9:13] CXXMethod=operator++:9:5
76f4a2713aSLionel Sambuc // CHECK: Punctuation: "++" [9:13 - 9:15] CXXMethod=operator++:9:5
77f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [9:15 - 9:16] CXXMethod=operator++:9:5
78*0a6a1f1dSLionel Sambuc // CHECK: Keyword: "int" [9:16 - 9:19] ParmDecl=:9:19 (Definition
79*0a6a1f1dSLionel Sambuc // CHECK: Punctuation: ")" [9:19 - 9:20] CXXMethod=operator++:9:5
80f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [9:20 - 9:21] StructDecl=X:7:8 (Definition)
81f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [10:1 - 10:2] StructDecl=X:7:8 (Definition)
82f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [10:2 - 10:3]
83f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [11:1 - 11:5] FunctionDecl=test2:11:6 (Definition)
84f4a2713aSLionel Sambuc // CHECK: Identifier: "test2" [11:6 - 11:11] FunctionDecl=test2:11:6 (Definition)
85f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [11:11 - 11:12] FunctionDecl=test2:11:6 (Definition)
86f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [11:12 - 11:13] TypeRef=struct X:7:8
87f4a2713aSLionel Sambuc // CHECK: Identifier: "x" [11:14 - 11:15] ParmDecl=x:11:14 (Definition)
88f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [11:15 - 11:16] FunctionDecl=test2:11:6 (Definition)
89f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [11:17 - 11:18] CompoundStmt=
90f4a2713aSLionel Sambuc // CHECK: Punctuation: "++" [12:3 - 12:5] CallExpr=operator++:8:5
91f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [12:5 - 12:6] ParenExpr=
92f4a2713aSLionel Sambuc // CHECK: Identifier: "x" [12:6 - 12:7] DeclRefExpr=x:11:14
93f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [12:7 - 12:8] ParenExpr=
94f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [12:8 - 12:9] CompoundStmt=
95f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [13:3 - 13:4] ParenExpr=
96f4a2713aSLionel Sambuc // CHECK: Identifier: "x" [13:4 - 13:5] DeclRefExpr=x:11:14
97f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [13:5 - 13:6] ParenExpr=
98f4a2713aSLionel Sambuc // CHECK: Punctuation: "++" [13:6 - 13:8] DeclRefExpr=operator++:9:5
99f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [13:8 - 13:9] CompoundStmt=
100f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [14:1 - 14:2] CompoundStmt=
101f4a2713aSLionel Sambuc // CHECK: Keyword: "struct" [16:1 - 16:7] StructDecl=S1:16:8 (Definition)
102f4a2713aSLionel Sambuc // CHECK: Identifier: "S1" [16:8 - 16:10] StructDecl=S1:16:8 (Definition)
103f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [16:11 - 16:12] StructDecl=S1:16:8 (Definition)
104f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [16:13 - 16:17] CXXMethod=f:16:18
105f4a2713aSLionel Sambuc // CHECK: Identifier: "f" [16:18 - 16:19] CXXMethod=f:16:18
106f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [16:19 - 16:20] CXXMethod=f:16:18
107f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [16:20 - 16:21] CXXMethod=f:16:18
108f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [16:21 - 16:22] StructDecl=S1:16:8 (Definition)
109f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [16:23 - 16:24] StructDecl=S1:16:8 (Definition)
110f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [16:24 - 16:25]
111f4a2713aSLionel Sambuc // CHECK: Keyword: "struct" [17:1 - 17:7] StructDecl=S2:17:8 (Definition)
112f4a2713aSLionel Sambuc // CHECK: Identifier: "S2" [17:8 - 17:10] StructDecl=S2:17:8 (Definition)
113f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [17:11 - 17:12] StructDecl=S2:17:8 (Definition)
114f4a2713aSLionel Sambuc // CHECK: Identifier: "S1" [17:13 - 17:15] TypeRef=struct S1:16:8
115f4a2713aSLionel Sambuc // CHECK: Punctuation: "*" [17:16 - 17:17] CXXMethod=operator->:17:17
116f4a2713aSLionel Sambuc // CHECK: Keyword: "operator" [17:17 - 17:25] CXXMethod=operator->:17:17
117f4a2713aSLionel Sambuc // CHECK: Punctuation: "->" [17:25 - 17:27] CXXMethod=operator->:17:17
118f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [17:27 - 17:28] CXXMethod=operator->:17:17
119f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [17:28 - 17:29] CXXMethod=operator->:17:17
120f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [17:29 - 17:30] StructDecl=S2:17:8 (Definition)
121f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [17:31 - 17:32] StructDecl=S2:17:8 (Definition)
122f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [17:32 - 17:33]
123f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [18:1 - 18:5] FunctionDecl=test3:18:6 (Definition)
124f4a2713aSLionel Sambuc // CHECK: Identifier: "test3" [18:6 - 18:11] FunctionDecl=test3:18:6 (Definition)
125f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [18:11 - 18:12] FunctionDecl=test3:18:6 (Definition)
126f4a2713aSLionel Sambuc // CHECK: Identifier: "S2" [18:12 - 18:14] TypeRef=struct S2:17:8
127f4a2713aSLionel Sambuc // CHECK: Identifier: "s2" [18:15 - 18:17] ParmDecl=s2:18:15 (Definition)
128f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [18:17 - 18:18] FunctionDecl=test3:18:6 (Definition)
129f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [18:19 - 18:20] CompoundStmt=
130f4a2713aSLionel Sambuc // CHECK: Identifier: "s2" [19:3 - 19:5] DeclRefExpr=s2:18:15
131f4a2713aSLionel Sambuc // CHECK: Punctuation: "->" [19:5 - 19:7] DeclRefExpr=operator->:17:17
132f4a2713aSLionel Sambuc // CHECK: Identifier: "f" [19:7 - 19:8] MemberRefExpr=f:16:18
133f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [19:8 - 19:9] CallExpr=f:16:18
134f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [19:9 - 19:10] CallExpr=f:16:18
135f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [19:10 - 19:11] CompoundStmt=
136f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [20:3 - 20:4] TypeRef=struct X:7:8
137f4a2713aSLionel Sambuc // CHECK: Identifier: "foo" [20:5 - 20:8] VarDecl=foo:20:5 (Definition)
138f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [20:8 - 20:9] DeclStmt=
139f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [21:1 - 21:2] CompoundStmt=
140f4a2713aSLionel Sambuc // CHECK: Keyword: "template" [23:1 - 23:9] ClassTemplate=TS:24:8 (Definition)
141f4a2713aSLionel Sambuc // CHECK: Punctuation: "<" [23:10 - 23:11] ClassTemplate=TS:24:8 (Definition)
142f4a2713aSLionel Sambuc // CHECK: Keyword: "bool" [23:11 - 23:15] NonTypeTemplateParameter=tfn:23:18 (Definition)
143f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [23:16 - 23:17] NonTypeTemplateParameter=tfn:23:18 (Definition)
144f4a2713aSLionel Sambuc // CHECK: Punctuation: "*" [23:17 - 23:18] NonTypeTemplateParameter=tfn:23:18 (Definition)
145f4a2713aSLionel Sambuc // CHECK: Identifier: "tfn" [23:18 - 23:21] NonTypeTemplateParameter=tfn:23:18 (Definition)
146f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [23:21 - 23:22] NonTypeTemplateParameter=tfn:23:18 (Definition)
147f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [23:22 - 23:23] NonTypeTemplateParameter=tfn:23:18 (Definition)
148f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [23:23 - 23:24] TypeRef=struct X:7:8
149f4a2713aSLionel Sambuc // CHECK: Punctuation: "*" [23:24 - 23:25] ParmDecl=:23:25 (Definition)
150*0a6a1f1dSLionel Sambuc // CHECK: Punctuation: ")" [23:25 - 23:26] NonTypeTemplateParameter=tfn:23:18 (Definition)
151f4a2713aSLionel Sambuc // CHECK: Punctuation: ">" [23:26 - 23:27] ClassTemplate=TS:24:8 (Definition)
152f4a2713aSLionel Sambuc // CHECK: Keyword: "struct" [24:1 - 24:7] ClassTemplate=TS:24:8 (Definition)
153f4a2713aSLionel Sambuc // CHECK: Identifier: "TS" [24:8 - 24:10] ClassTemplate=TS:24:8 (Definition)
154f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [24:11 - 24:12] ClassTemplate=TS:24:8 (Definition)
155f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [25:3 - 25:7] CXXMethod=foo:25:8
156f4a2713aSLionel Sambuc // CHECK: Identifier: "foo" [25:8 - 25:11] CXXMethod=foo:25:8
157f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [25:11 - 25:12] CXXMethod=foo:25:8
158f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [25:12 - 25:13] CXXMethod=foo:25:8
159f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [25:13 - 25:14] ClassTemplate=TS:24:8 (Definition)
160f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [26:1 - 26:2] ClassTemplate=TS:24:8 (Definition)
161f4a2713aSLionel Sambuc // CHECK: Punctuation: ";" [26:2 - 26:3]
162f4a2713aSLionel Sambuc // CHECK: Keyword: "template" [28:1 - 28:9] CXXMethod=foo:29:15 (Definition)
163f4a2713aSLionel Sambuc // CHECK: Punctuation: "<" [28:10 - 28:11] CXXMethod=foo:29:15 (Definition)
164f4a2713aSLionel Sambuc // CHECK: Keyword: "bool" [28:11 - 28:15] NonTypeTemplateParameter=tfn:28:18 (Definition)
165f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [28:16 - 28:17] NonTypeTemplateParameter=tfn:28:18 (Definition)
166f4a2713aSLionel Sambuc // CHECK: Punctuation: "*" [28:17 - 28:18] NonTypeTemplateParameter=tfn:28:18 (Definition)
167f4a2713aSLionel Sambuc // CHECK: Identifier: "tfn" [28:18 - 28:21] NonTypeTemplateParameter=tfn:28:18 (Definition)
168f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [28:21 - 28:22] NonTypeTemplateParameter=tfn:28:18 (Definition)
169f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [28:22 - 28:23] NonTypeTemplateParameter=tfn:28:18 (Definition)
170f4a2713aSLionel Sambuc // CHECK: Identifier: "X" [28:23 - 28:24] TypeRef=struct X:7:8
171f4a2713aSLionel Sambuc // CHECK: Punctuation: "*" [28:24 - 28:25] ParmDecl=:28:25 (Definition)
172*0a6a1f1dSLionel Sambuc // CHECK: Punctuation: ")" [28:25 - 28:26] NonTypeTemplateParameter=tfn:28:18 (Definition)
173f4a2713aSLionel Sambuc // CHECK: Punctuation: ">" [28:26 - 28:27] CXXMethod=foo:29:15 (Definition)
174f4a2713aSLionel Sambuc // CHECK: Keyword: "void" [29:1 - 29:5] CXXMethod=foo:29:15 (Definition)
175f4a2713aSLionel Sambuc // CHECK: Identifier: "TS" [29:6 - 29:8] TemplateRef=TS:24:8
176f4a2713aSLionel Sambuc // CHECK: Punctuation: "<" [29:8 - 29:9] CXXMethod=foo:29:15 (Definition)
177f4a2713aSLionel Sambuc // CHECK: Identifier: "tfn" [29:9 - 29:12] DeclRefExpr=tfn:28:18
178f4a2713aSLionel Sambuc // CHECK: Punctuation: ">" [29:12 - 29:13] CXXMethod=foo:29:15 (Definition)
179f4a2713aSLionel Sambuc // CHECK: Punctuation: "::" [29:13 - 29:15] CXXMethod=foo:29:15 (Definition)
180f4a2713aSLionel Sambuc // CHECK: Identifier: "foo" [29:15 - 29:18] CXXMethod=foo:29:15 (Definition)
181f4a2713aSLionel Sambuc // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition)
182f4a2713aSLionel Sambuc // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition)
183f4a2713aSLionel Sambuc // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt=
184f4a2713aSLionel Sambuc // CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
185*0a6a1f1dSLionel Sambuc // CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
186*0a6a1f1dSLionel Sambuc // CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
187*0a6a1f1dSLionel Sambuc
188*0a6a1f1dSLionel Sambuc // RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
189*0a6a1f1dSLionel Sambuc // CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
190*0a6a1f1dSLionel Sambuc // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt=
191*0a6a1f1dSLionel Sambuc // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition)
192*0a6a1f1dSLionel Sambuc // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition)
193*0a6a1f1dSLionel Sambuc // CHECK2: Punctuation: "=" [32:13 - 32:14] VarDecl=p:32:11 (Definition)
194