1 // Test without serialization:
2 // RUN: %clang_cc1 -std=gnu11 -ast-dump %s \
3 // RUN: | FileCheck -strict-whitespace %s
4 //
5 // Test with serialization:
6 // RUN: %clang_cc1 -std=gnu11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c -std=gnu11 -include-pch %t -ast-dump-all /dev/null \
8 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
9 // RUN: | FileCheck -strict-whitespace %s
10
11 int TestLocation = 0;
12 // CHECK: VarDecl{{.*}}TestLocation
13 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:20> 'int' 0
14
15 int TestIndent = 1 + (1);
16 // CHECK: VarDecl{{.*}}TestIndent
17 // CHECK-NEXT: {{^}}| `-BinaryOperator{{[^()]*$}}
18 // CHECK-NEXT: {{^}}| |-IntegerLiteral{{.*0[^()]*$}}
19 // CHECK-NEXT: {{^}}| `-ParenExpr{{.*0[^()]*$}}
20 // CHECK-NEXT: {{^}}| `-IntegerLiteral{{.*0[^()]*$}}
21
TestDeclStmt()22 void TestDeclStmt() {
23 int x = 0;
24 int y, z;
25 }
26 // CHECK: FunctionDecl{{.*}}TestDeclStmt
27 // CHECK-NEXT: CompoundStmt
28 // CHECK-NEXT: DeclStmt
29 // CHECK-NEXT: VarDecl{{.*}}x
30 // CHECK-NEXT: IntegerLiteral
31 // CHECK-NEXT: DeclStmt
32 // CHECK-NEXT: VarDecl{{.*}}y
33 // CHECK-NEXT: VarDecl{{.*}}z
34
35 int TestOpaqueValueExpr = 0 ?: 1;
36 // CHECK: VarDecl{{.*}}TestOpaqueValueExpr
37 // CHECK-NEXT: BinaryConditionalOperator
38 // CHECK-NEXT: IntegerLiteral
39 // CHECK-NEXT: OpaqueValueExpr
40 // CHECK-NEXT: IntegerLiteral
41 // CHECK-NEXT: OpaqueValueExpr
42 // CHECK-NEXT: IntegerLiteral
43 // CHECK-NEXT: IntegerLiteral
44
TestUnaryOperatorExpr(void)45 void TestUnaryOperatorExpr(void) {
46 char T1 = 1;
47 int T2 = 1;
48
49 T1++;
50 T2++;
51 // CHECK: UnaryOperator{{.*}}postfix '++' cannot overflow
52 // CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
53 // CHECK-NOT: UnaryOperator{{.*}}postfix '++' cannot overflow
54 // CHECK: DeclRefExpr{{.*}}'T2' 'int'
55
56 -T1;
57 -T2;
58 // CHECK: UnaryOperator{{.*}}prefix '-' cannot overflow
59 // CHECK-NEXT: ImplicitCastExpr
60 // CHECK-NEXT: ImplicitCastExpr
61 // CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
62 // CHECK-NOT: UnaryOperator{{.*}}prefix '-' cannot overflow
63 // CHECK: ImplicitCastExpr
64 // CHECK: DeclRefExpr{{.*}}'T2' 'int'
65
66 ~T1;
67 ~T2;
68 // CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
69 // CHECK-NEXT: ImplicitCastExpr
70 // CHECK-NEXT: ImplicitCastExpr
71 // CHECK-NEXT: DeclRefExpr{{.*}}'T1' 'char'
72 // CHECK: UnaryOperator{{.*}}prefix '~' cannot overflow
73 // CHECK-NEXT: ImplicitCastExpr
74 // CHECK-NEXT: DeclRefExpr{{.*}}'T2' 'int'
75 }
76
TestGenericSelectionExpressions(int i)77 void TestGenericSelectionExpressions(int i) {
78 _Generic(i, int : 12);
79 // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
80 // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
81 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
82 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
83 // FIXME: note that the following test line has a spurious whitespace.
84 // CHECK-NEXT: case 'int' selected
85 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
86 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
87 _Generic(i, int : 12, default : 0);
88 // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
89 // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
90 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
91 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
92 // FIXME: note that the following test line has a spurious whitespace.
93 // CHECK-NEXT: case 'int' selected
94 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
95 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
96 // CHECK-NEXT: default
97 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:35> 'int' 0
98 _Generic(i, default : 0, int : 12);
99 // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
100 // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
101 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
102 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
103 // CHECK-NEXT: default
104 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:25> 'int' 0
105 // FIXME: note that the following test line has a spurious whitespace.
106 // CHECK-NEXT: case 'int' selected
107 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
108 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:34> 'int' 12
109 _Generic(i, int : 12, float : 10, default : 100);
110 // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:50> 'int'
111 // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
112 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
113 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
114 // FIXME: note that the following test line has a spurious whitespace.
115 // CHECK-NEXT: case 'int' selected
116 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
117 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
118 // FIXME: note that the following test line has a spurious whitespace.
119 // CHECK-NEXT: case 'float'
120 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'float'
121 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:33> 'int' 10
122 // CHECK-NEXT: default
123 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:47> 'int' 100
124
125 int j = _Generic(i, int : 12);
126 // CHECK: DeclStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:32>
127 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:3, col:31> col:7 j 'int' cinit
128 // CHECK-NEXT: GenericSelectionExpr 0x{{[^ ]*}} <col:11, col:31> 'int'
129 // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
130 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:20> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
131 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
132 // FIXME: note that the following test line has a spurious whitespace.
133 // CHECK-NEXT: case 'int' selected
134 // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
135 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:29> 'int' 12
136 }
137
TestLabelsAndGoto(void)138 void TestLabelsAndGoto(void) {
139 // Note: case and default labels are handled by TestSwitch().
140
141 label1:
142 ;
143 // CHECK: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label1'
144 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:3>
145
146 goto label2;
147 // CHECK-NEXT: GotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'label2' 0x{{[^ ]*}}
148
149 label2:
150 0;
151 // CHECK-NEXT: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label2'
152 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:3> 'int' 0
153
154 void *ptr = &&label1;
155 // CHECK-NEXT: DeclStmt
156 // CHECK-NEXT: VarDecl
157 // CHECK-NEXT: AddrLabelExpr 0x{{[^ ]*}} <col:15, col:17> 'void *' label1 0x{{[^ ]*}}
158
159 goto *ptr;
160 // CHECK-NEXT: IndirectGotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9>
161 // CHECK-NEXT: ImplicitCastExpr
162 // CHECK-NEXT: ImplicitCastExpr
163 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:9> 'void *' lvalue Var 0x{{[^ ]*}} 'ptr' 'void *'
164 }
165
TestSwitch(int i)166 void TestSwitch(int i) {
167 switch (i) {
168 // CHECK: SwitchStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, line:[[@LINE+32]]:3>
169 // CHECK-NEXT: ImplicitCastExpr
170 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
171 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:14, line:[[@LINE+29]]:3>
172 case 0:
173 break;
174 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
175 // CHECK-NEXT: ConstantExpr
176 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 0
177 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
178 case 1:
179 case 2:
180 break;
181 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:5>
182 // CHECK-NEXT: ConstantExpr
183 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 1
184 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:3, line:[[@LINE-4]]:5>
185 // CHECK-NEXT: ConstantExpr
186 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 2
187 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-7]]:5>
188 default:
189 break;
190 // CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
191 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <col:5>
192 case 3 ... 5:
193 break;
194 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5> gnu_range
195 // CHECK-NEXT: ConstantExpr
196 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 3
197 // CHECK-NEXT: ConstantExpr
198 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 5
199 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
200 }
201 }
202
TestIf(_Bool b)203 void TestIf(_Bool b) {
204 if (b)
205 ;
206 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
207 // CHECK-NEXT: ImplicitCastExpr
208 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
209 // CHECK-NEXT: NullStmt
210
211 if (b) {}
212 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11>
213 // CHECK-NEXT: ImplicitCastExpr
214 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
215 // CHECK-NEXT: CompoundStmt
216
217 if (b)
218 ;
219 else
220 ;
221 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
222 // CHECK-NEXT: ImplicitCastExpr
223 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
224 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
225 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:5>
226
227 if (b) {}
228 else {}
229 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:9> has_else
230 // CHECK-NEXT: ImplicitCastExpr
231 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
232 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:11>
233 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:8, col:9>
234
235 if (b)
236 ;
237 else if (b)
238 ;
239 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
240 // CHECK-NEXT: ImplicitCastExpr
241 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
242 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
243 // CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:8, line:[[@LINE-5]]:5>
244 // CHECK-NEXT: ImplicitCastExpr
245 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
246 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
247
248 if (b)
249 ;
250 else if (b)
251 ;
252 else
253 ;
254 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:3, line:[[@LINE-1]]:5> has_else
255 // CHECK-NEXT: ImplicitCastExpr
256 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
257 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
258 // CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:8, line:[[@LINE-5]]:5> has_else
259 // CHECK-NEXT: ImplicitCastExpr
260 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
261 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-10]]:5>
262 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-9]]:5>
263 }
264
TestIteration(_Bool b)265 void TestIteration(_Bool b) {
266 while (b)
267 ;
268 // CHECK: WhileStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
269 // CHECK-NEXT: ImplicitCastExpr
270 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
271 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
272
273 do
274 ;
275 while (b);
276 // CHECK: DoStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:11>
277 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:5>
278 // CHECK-NEXT: ImplicitCastExpr
279 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
280
281 for (int i = 0; i < 10; ++i)
282 ;
283 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
284 // CHECK-NEXT: DeclStmt
285 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:8, col:16> col:12 used i 'int' cinit
286 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 0
287 // CHECK-NEXT: <<<NULL>>>
288 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '<'
289 // CHECK-NEXT: ImplicitCastExpr
290 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
291 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 10
292 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:27, col:29> 'int' prefix '++'
293 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:29> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
294 // CHECK-NEXT: NullStmt
295
296 for (b; b; b)
297 ;
298 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
299 // CHECK-NEXT: ImplicitCastExpr
300 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
301 // CHECK-NEXT: <<<NULL>>>
302 // CHECK-NEXT: ImplicitCastExpr
303 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
304 // CHECK-NEXT: ImplicitCastExpr
305 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
306 // CHECK-NEXT: NullStmt
307
308 for (; b; b = !b)
309 ;
310 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
311 // CHECK-NEXT: <<<NULL>>>
312 // CHECK-NEXT: <<<NULL>>>
313 // CHECK-NEXT: ImplicitCastExpr
314 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
315 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:13, col:18> '_Bool' '='
316 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
317 // CHECK-NEXT: ImplicitCastExpr
318 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:17, col:18> 'int' prefix '!' cannot overflow
319 // CHECK-NEXT: ImplicitCastExpr
320 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:18> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
321 // CHECK-NEXT: NullStmt
322
323 for (; b;)
324 ;
325 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
326 // CHECK-NEXT: <<<NULL>>>
327 // CHECK-NEXT: <<<NULL>>>
328 // CHECK-NEXT: ImplicitCastExpr
329 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
330 // CHECK-NEXT: <<<NULL>>>
331 // CHECK-NEXT: NullStmt
332
333 for (;; b = !b)
334 ;
335 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
336 // CHECK-NEXT: <<<NULL>>>
337 // CHECK-NEXT: <<<NULL>>>
338 // CHECK-NEXT: <<<NULL>>>
339 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-6]]:11, col:16> '_Bool' '='
340 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
341 // CHECK-NEXT: ImplicitCastExpr
342 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:15, col:16> 'int' prefix '!' cannot overflow
343 // CHECK-NEXT: ImplicitCastExpr
344 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
345 // CHECK-NEXT: NullStmt
346
347 for (;;)
348 ;
349 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
350 // CHECK-NEXT: <<<NULL>>>
351 // CHECK-NEXT: <<<NULL>>>
352 // CHECK-NEXT: <<<NULL>>>
353 // CHECK-NEXT: <<<NULL>>>
354 // CHECK-NEXT: NullStmt
355 }
356
TestJumps(void)357 void TestJumps(void) {
358 // goto and computed goto was tested in TestLabelsAndGoto().
359
360 while (1) {
361 continue;
362 // CHECK: ContinueStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
363 break;
364 // CHECK: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
365 }
366 return;
367 // CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3>
368
369 return TestSwitch(1);
370 // CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22>
371 // CHECK-NEXT: CallExpr 0x{{[^ ]*}} <col:10, col:22> 'void'
372 }
373
TestMiscStmts(void)374 void TestMiscStmts(void) {
375 ({int a = 10; a;});
376 // CHECK: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'int'
377 // CHECK-NEXT: CompoundStmt
378 // CHECK-NEXT: DeclStmt
379 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
380 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
381 // CHECK-NEXT: ImplicitCastExpr
382 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
383 ({int a = 10; a;;; });
384 // CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
385 // CHECK-NEXT: CompoundStmt
386 // CHECK-NEXT: DeclStmt
387 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
388 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
389 // CHECK-NEXT: ImplicitCastExpr
390 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
391 // CHECK-NEXT: NullStmt
392 // CHECK-NEXT: NullStmt
393 }
394