[ELF] Avoid make in elf::writeARMCmseImportLib
[llvm-project.git] / clang / test / AST / ast-dump-recovery.c
blob68d3f182dd9f64f165197fee14e122d7ea3fd930
1 // RUN: not %clang_cc1 -triple x86_64-unknown-unknown -frecovery-ast -fno-recovery-ast-type -ast-dump %s | FileCheck -strict-whitespace %s
3 int some_func(int);
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();
10 const int a = 1;
12 // CHECK: VarDecl {{.*}} postfix_inc
13 // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
14 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
15 int postfix_inc = a++;
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);
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;
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.
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
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();
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;
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;
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);
81 // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors <Dependent>
82 // CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
83 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
84 (float)some_func();
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);
95 extern void ext();
96 // CHECK: CallExpr {{.*}} '<dependent type>' contains-errors
97 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
98 // CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
99 ext(undef_var);
102 // Verify no crash.
103 void test4() {
104 enum GH62446 {
105 // CHECK: RecoveryExpr {{.*}} '<dependent type>' contains-errors lvalue
106 // CHECK-NEXT: |-StringLiteral {{.*}} "a"
107 // CHECK-NEXT: `-IntegerLiteral {{.*}} 2
108 invalid_enum_value = "a" * 2,
113 // Verify no crash
114 void test5_GH62711() {
115 // CHECK: VAArgExpr {{.*}} 'int' contains-errors
116 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '<dependent type>' contains-errors
117 // CHECK-NEXT: | `-RecoveryExpr {{.*}} '<dependent type>' contains-errors
118 if (__builtin_va_arg(undef, int) << 1);
121 void test6_GH50244() {
122 double array[16];
123 // CHECK: UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' contains-errors sizeof
124 // CHECK-NEXT: `-CallExpr {{.*}} '<dependent type>' contains-errors
125 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int ()'
126 // CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>'
127 sizeof array / sizeof foo(undef);
130 // No crash on DeclRefExpr that refers to ValueDecl with invalid initializers.
131 void test7() {
132 int b[] = {""()};
134 // CHECK: CStyleCastExpr {{.*}} 'unsigned int' contains-errors
135 // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int[]' contains-errors
136 (unsigned) b; // GH50236
138 // CHECK: BinaryOperator {{.*}} '<dependent type>' contains-errors '+'
139 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int[]' contains-errors
140 // CHECK-NEXT: `-IntegerLiteral {{.*}}
141 b + 1; // GH50243
143 // CHECK: CallExpr {{.*}} '<dependent type>' contains-errors
144 // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int ()' Function
145 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'int[]' contains-errors
146 return c(b); // GH48636
148 int test8_GH50320_b[] = {""()};
149 // CHECK: ArraySubscriptExpr {{.*}} 'int' contains-errors lvalue
150 int test8 = test_8GH50320_b[0];