[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ast-dump-stmt.c
blob5c44fea2df6e7c5c57c5ce9a419e9dff0116ece4
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
11 int TestLocation = 0;
12 // CHECK: VarDecl{{.*}}TestLocation
13 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:20> 'int' 0
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[^()]*$}}
22 void TestDeclStmt(void) {
23 int x = 0;
24 int y, z;
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
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
45 void TestUnaryOperatorExpr(void) {
46 char T1 = 1;
47 int T2 = 1;
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'
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'
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'
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
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
138 void TestLabelsAndGoto(void) {
139 // Note: case and default labels are handled by TestSwitch().
141 label1:
143 // CHECK: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label1'
144 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:3>
146 goto label2;
147 // CHECK-NEXT: GotoStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:8> 'label2' 0x{{[^ ]*}}
149 label2:
151 // CHECK-NEXT: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:1, line:[[@LINE-1]]:3> 'label2'
152 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:3> 'int' 0
154 void *ptr = &&label1;
155 // CHECK-NEXT: DeclStmt
156 // CHECK-NEXT: VarDecl
157 // CHECK-NEXT: AddrLabelExpr 0x{{[^ ]*}} <col:15, col:17> 'void *' label1 0x{{[^ ]*}}
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 *'
165 label3:
166 // CHECK-NEXT: LabelStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:1, col:7> 'label3'
167 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:7>
170 void TestSwitch(int i) {
171 switch (i) {
172 // CHECK: SwitchStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, line:[[@LINE+37]]:3>
173 // CHECK-NEXT: ImplicitCastExpr
174 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
175 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:14, line:[[@LINE+34]]:3>
176 case 0:
177 break;
178 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
179 // CHECK-NEXT: ConstantExpr
180 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 0
181 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
182 case 1:
183 case 2:
184 break;
185 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:5>
186 // CHECK-NEXT: ConstantExpr
187 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 1
188 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:3, line:[[@LINE-4]]:5>
189 // CHECK-NEXT: ConstantExpr
190 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 2
191 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-7]]:5>
192 default:
193 break;
194 // CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
195 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <col:5>
196 case 3 ... 5:
197 break;
198 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5> gnu_range
199 // CHECK-NEXT: ConstantExpr
200 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 3
201 // CHECK-NEXT: ConstantExpr
202 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:14> 'int' 5
203 // CHECK-NEXT: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
204 case 6:
205 // CHECK-NEXT: CaseStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:9>
206 // CHECK-NEXT: ConstantExpr
207 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:8> 'int' 6
208 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:9>
211 switch(i){
212 // CHECK: SwitchStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, line:[[@LINE+7]]:3>
213 // CHECK-NEXT: ImplicitCastExpr
214 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
215 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:12, line:[[@LINE+4]]:3>
216 default:
217 // CHECK-NEXT: DefaultStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:10>
218 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <col:10>
222 void TestIf(_Bool b) {
223 if (b)
225 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
226 // CHECK-NEXT: ImplicitCastExpr
227 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
228 // CHECK-NEXT: NullStmt
230 if (b) {}
231 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:11>
232 // CHECK-NEXT: ImplicitCastExpr
233 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
234 // CHECK-NEXT: CompoundStmt
236 if (b)
238 else
240 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
241 // CHECK-NEXT: ImplicitCastExpr
242 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
243 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
244 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:5>
246 if (b) {}
247 else {}
248 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:9> has_else
249 // CHECK-NEXT: ImplicitCastExpr
250 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
251 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <col:10, col:11>
252 // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} <line:[[@LINE-5]]:8, col:9>
254 if (b)
256 else if (b)
258 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:3, line:[[@LINE-1]]:5> has_else
259 // CHECK-NEXT: ImplicitCastExpr
260 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
261 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:5>
262 // CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:8, line:[[@LINE-5]]:5>
263 // CHECK-NEXT: ImplicitCastExpr
264 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
265 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
267 if (b)
269 else if (b)
271 else
273 // CHECK: IfStmt 0x{{[^ ]*}} <line:[[@LINE-6]]:3, line:[[@LINE-1]]:5> has_else
274 // CHECK-NEXT: ImplicitCastExpr
275 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:7> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
276 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:5>
277 // CHECK-NEXT: IfStmt 0x{{[^ ]*}} <line:[[@LINE-8]]:8, line:[[@LINE-5]]:5> has_else
278 // CHECK-NEXT: ImplicitCastExpr
279 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
280 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-10]]:5>
281 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-9]]:5>
284 void TestIteration(_Bool b) {
285 while (b)
287 // CHECK: WhileStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
288 // CHECK-NEXT: ImplicitCastExpr
289 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
290 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-4]]:5>
294 while (b);
295 // CHECK: DoStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:3, line:[[@LINE-1]]:11>
296 // CHECK-NEXT: NullStmt 0x{{[^ ]*}} <line:[[@LINE-3]]:5>
297 // CHECK-NEXT: ImplicitCastExpr
298 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
300 for (int i = 0; i < 10; ++i)
302 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
303 // CHECK-NEXT: DeclStmt
304 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:8, col:16> col:12 used i 'int' cinit
305 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:16> 'int' 0
306 // CHECK-NEXT: <<<NULL>>>
307 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:19, col:23> 'int' '<'
308 // CHECK-NEXT: ImplicitCastExpr
309 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:19> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
310 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:23> 'int' 10
311 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:27, col:29> 'int' prefix '++'
312 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:29> 'int' lvalue Var 0x{{[^ ]*}} 'i' 'int'
313 // CHECK-NEXT: NullStmt
315 for (b; b; b)
317 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
318 // CHECK-NEXT: ImplicitCastExpr
319 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
320 // CHECK-NEXT: <<<NULL>>>
321 // CHECK-NEXT: ImplicitCastExpr
322 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
323 // CHECK-NEXT: ImplicitCastExpr
324 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:14> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
325 // CHECK-NEXT: NullStmt
327 for (; b; b = !b)
329 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
330 // CHECK-NEXT: <<<NULL>>>
331 // CHECK-NEXT: <<<NULL>>>
332 // CHECK-NEXT: ImplicitCastExpr
333 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
334 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <col:13, col:18> '_Bool' '='
335 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:13> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
336 // CHECK-NEXT: ImplicitCastExpr
337 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:17, col:18> 'int' prefix '!' cannot overflow
338 // CHECK-NEXT: ImplicitCastExpr
339 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:18> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
340 // CHECK-NEXT: NullStmt
342 for (; b;)
344 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
345 // CHECK-NEXT: <<<NULL>>>
346 // CHECK-NEXT: <<<NULL>>>
347 // CHECK-NEXT: ImplicitCastExpr
348 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:10> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
349 // CHECK-NEXT: <<<NULL>>>
350 // CHECK-NEXT: NullStmt
352 for (;; b = !b)
354 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
355 // CHECK-NEXT: <<<NULL>>>
356 // CHECK-NEXT: <<<NULL>>>
357 // CHECK-NEXT: <<<NULL>>>
358 // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} <line:[[@LINE-6]]:11, col:16> '_Bool' '='
359 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:11> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
360 // CHECK-NEXT: ImplicitCastExpr
361 // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}} <col:15, col:16> 'int' prefix '!' cannot overflow
362 // CHECK-NEXT: ImplicitCastExpr
363 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:16> '_Bool' lvalue ParmVar 0x{{[^ ]*}} 'b' '_Bool'
364 // CHECK-NEXT: NullStmt
366 for (;;)
368 // CHECK: ForStmt 0x{{[^ ]*}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:5>
369 // CHECK-NEXT: <<<NULL>>>
370 // CHECK-NEXT: <<<NULL>>>
371 // CHECK-NEXT: <<<NULL>>>
372 // CHECK-NEXT: <<<NULL>>>
373 // CHECK-NEXT: NullStmt
376 void TestJumps(void) {
377 // goto and computed goto was tested in TestLabelsAndGoto().
379 while (1) {
380 continue;
381 // CHECK: ContinueStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
382 break;
383 // CHECK: BreakStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:5>
385 return;
386 // CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3>
388 return TestSwitch(1);
389 // CHECK: ReturnStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:22>
390 // CHECK-NEXT: CallExpr 0x{{[^ ]*}} <col:10, col:22> 'void'
393 void TestMiscStmts(void) {
394 ({int a = 10; a;});
395 // CHECK: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:20> 'int'
396 // CHECK-NEXT: CompoundStmt
397 // CHECK-NEXT: DeclStmt
398 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
399 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
400 // CHECK-NEXT: ImplicitCastExpr
401 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
402 ({int a = 10; a;;; });
403 // CHECK-NEXT: StmtExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
404 // CHECK-NEXT: CompoundStmt
405 // CHECK-NEXT: DeclStmt
406 // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:5, col:13> col:9 used a 'int' cinit
407 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:13> 'int' 10
408 // CHECK-NEXT: ImplicitCastExpr
409 // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:17> 'int' lvalue Var 0x{{[^ ]*}} 'a' 'int'
410 // CHECK-NEXT: NullStmt
411 // CHECK-NEXT: NullStmt