[clang][NFC] simplify the unset check in `ParseLabeledStatement` (#117430)
[llvm-project.git] / clang / test / AST / loop-recovery.cpp
blobb1e4ecf1c2ce4fc55934124752b7ac6f514796b8
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
2 // RUN: not %clang_cc1 -ast-dump %s -std=c++17 | FileCheck %s
4 void test() {
5 while(!!!) // expected-error {{expected expression}}
6 int whileBody;
7 // CHECK: WhileStmt
8 // CHECK: RecoveryExpr {{.*}} <line:{{.*}}:9, col:11> 'bool'
9 // CHECK: whileBody 'int'
11 for(!!!) // expected-error {{expected expression}} expected-error {{expected ';'}}
12 int forBody;
13 // CHECK: ForStmt
14 // FIXME: the AST should have a RecoveryExpr to distinguish from for(;;)
15 // CHECK-NOT: RecoveryExpr
16 // CHECK: forBody 'int'
18 for(auto c : !!!) // expected-error {{expected expression}}
19 int forEachBody;
20 // FIXME: parse the foreach body
21 // CHECK-NOT: CXXForRangeStmt
22 // CHECK-NOT: forEachBody 'int'
25 int doBody;
26 while(!!!); // expected-error {{expected expression}}
27 // CHECK: DoStmt
28 // CHECK: doBody 'int'
29 // CHECK: RecoveryExpr {{.*}} <line:{{.*}}:9, col:11> 'bool'
31 if(!!!) // expected-error {{expected expression}}
32 int ifBody;
33 else
34 int elseBody;
35 // CHECK: IfStmt
36 // CHECK: RecoveryExpr {{.*}} <line:{{.*}}:6, col:8> 'bool'
37 // CHECK: ifBody 'int'
38 // CHECK: elseBody 'int'
40 switch(!!!) // expected-error {{expected expression}}
41 int switchBody;
42 // CHECK: SwitchStmt
43 // CHECK: RecoveryExpr {{.*}} <line:{{.*}}:10, col:12> 'int'
44 // CHECK: switchBody 'int'
46 switch (;) // expected-error {{expected expression}}
47 int switchBody;
48 // CHECK: SwitchStmt
49 // CHECK: NullStmt
50 // CHECK: RecoveryExpr {{.*}} <col:11> 'int'
51 // CHECK: switchBody 'int'
53 switch (;;) // expected-error {{expected expression}}
54 int switchBody;
55 // CHECK: SwitchStmt
56 // CHECK: NullStmt
57 // CHECK: RecoveryExpr {{.*}} <col:11, col:12> 'int'
58 // CHECK: switchBody 'int'
60 switch (!!!;) // expected-error {{expected expression}}
61 int switchBody;
62 // CHECK: SwitchStmt
63 // CHECK: RecoveryExpr {{.*}} <line:{{.*}}:11, col:14> 'int'
64 // CHECK: switchBody 'int'