1 // RUN: not %clang_cc1 -triple x86_64-unknown-unknown -frecovery-ast -fno-recovery-ast-type -ast-dump %s | FileCheck -strict-whitespace %s
2
3 int some_func(int);
4
5 // CHECK: VarDecl {{.*}} unmatch_arg_call 'int' cinit
6 // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
7 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
8 int unmatch_arg_call = some_func();
9
10 const int a = 1;
11
12 // CHECK: VarDecl {{.*}} postfix_inc
13 // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
14 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
15 int postfix_inc = a++;
16
17 // CHECK: VarDecl {{.*}} unary_address
18 // CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
19 // CHECK-NEXT: `-ParenExpr {{.*}}
20 // CHECK-NEXT: `-BinaryOperator {{.*}} '+'
21 // CHECK-NEXT: |-ImplicitCastExpr
22 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'a'
23 // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int'
24 int unary_address = &(a + 1);
25
26 // CHECK: VarDecl {{.*}} ternary 'int' cinit
27 // CHECK-NEXT: `-ConditionalOperator {{.*}}
28 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'a'
29 // CHECK-NEXT: |-RecoveryExpr {{.*}}
30 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
31 int ternary = a ? undef : a;
32
test1()33 void test1() {
34 // CHECK: `-RecoveryExpr {{.*}} contains-errors
35 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a' 'const int'
36 static int foo = a++; // verify no crash on local static var decl.
37 }
38
test2()39 void test2() {
40 int* ptr;
41 // CHECK: BinaryOperator {{.*}} 'int *' contains-errors '='
42 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *'
43 // CHECK-NEXT: `-RecoveryExpr {{.*}}
44 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
45 ptr = some_func(); // should not crash
46
47 int compoundOp;
48 // CHECK: CompoundAssignOperator {{.*}} 'int' contains-errors '+='
49 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'compoundOp'
50 // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
51 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
52 compoundOp += some_func();
53
54 // CHECK: BinaryOperator {{.*}} 'int' contains-errors '||'
55 // CHECK-NEXT: |-RecoveryExpr {{.*}}
56 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'some_func'
57 // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
58 some_func() || 1;
59
60 // CHECK: BinaryOperator {{.*}} '<dependent type>' contains-errors ','
61 // CHECK-NEXT: |-IntegerLiteral {{.*}} 'int' 1
62 // CHECK-NEXT: `-RecoveryExpr {{.*}}
63 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
64 1, some_func();
65 // CHECK: BinaryOperator {{.*}} 'int' contains-errors ','
66 // CHECK-NEXT: |-RecoveryExpr {{.*}} '<dependent type>'
67 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'some_func'
68 // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
69 some_func(), 1;
70
71 // conditional operator (comparison is invalid)
72 float f;
73 // CHECK: ConditionalOperator {{.*}} '<dependent type>' contains-errors
74 // CHECK-NEXT: |-RecoveryExpr {{.*}} '<dependent type>'
75 // CHECK-NEXT: | |-DeclRefExpr {{.*}} 'int *' lvalue
76 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'float' lvalue
77 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int *' lvalue
78 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'float' lvalue
79 (ptr > f ? ptr : f);
80
81 // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors <Dependent>
82 // CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
83 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
84 (float)some_func();
85 }
86
test3()87 void test3() {
88 // CHECK: CallExpr {{.*}} '<dependent type>' contains-errors
89 // CHECK-NEXT: |-ParenExpr {{.*}} contains-errors lvalue
90 // CHECK-NEXT: | `-RecoveryExpr {{.*}} contains-errors
91 // CHECK-NEXT: | `-DeclRefExpr {{.*}} '__builtin_classify_type'
92 // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
93 (*__builtin_classify_type)(1);
94
95 extern void ext();
96 // CHECK: CallExpr {{.*}} 'void' contains-errors
97 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
98 // CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
99 ext(undef_var);
100 }
101