1*733edf97SHaojian Wu // RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -ast-dump -frecovery-ast %s | FileCheck -strict-whitespace %s
2*733edf97SHaojian Wu 
3*733edf97SHaojian Wu // Check errors flag is set for RecoveryExpr.
4*733edf97SHaojian Wu //
5*733edf97SHaojian Wu // CHECK:     VarDecl {{.*}} a
6*733edf97SHaojian Wu // CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
7*733edf97SHaojian Wu // CHECK-NEXT:  `-UnresolvedLookupExpr {{.*}} 'bar'
8*733edf97SHaojian Wu int a = bar();
9*733edf97SHaojian Wu 
10*733edf97SHaojian Wu // The flag propagates through more complicated calls.
11*733edf97SHaojian Wu //
12*733edf97SHaojian Wu // CHECK:     VarDecl {{.*}} b
13*733edf97SHaojian Wu // CHECK-NEXT:`-CallExpr {{.*}} contains-errors
14*733edf97SHaojian Wu // CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'bar'
15*733edf97SHaojian Wu // CHECK-NEXT:  |-RecoveryExpr {{.*}} contains-errors
16*733edf97SHaojian Wu // CHECK-NEXT:  | `-UnresolvedLookupExpr {{.*}} 'baz'
17*733edf97SHaojian Wu // CHECK-NEXT:   `-RecoveryExpr {{.*}} contains-errors
18*733edf97SHaojian Wu // CHECK-NEXT:     `-UnresolvedLookupExpr {{.*}} 'qux'
19*733edf97SHaojian Wu int b = bar(baz(), qux());
20*733edf97SHaojian Wu 
21*733edf97SHaojian Wu // Also propagates through more complicated expressions.
22*733edf97SHaojian Wu //
23*733edf97SHaojian Wu // CHECK:     |-VarDecl {{.*}} c
24*733edf97SHaojian Wu // CHECK-NEXT:| `-BinaryOperator {{.*}} '<dependent type>' contains-errors '*'
25*733edf97SHaojian Wu // CHECK-NEXT:|   |-UnaryOperator {{.*}} '<dependent type>' contains-errors prefix '&'
26*733edf97SHaojian Wu // CHECK-NEXT:|   | `-ParenExpr {{.*}} '<dependent type>' contains-errors
27*733edf97SHaojian Wu // CHECK-NEXT:|   |   `-BinaryOperator {{.*}} '<dependent type>' contains-errors '+'
28*733edf97SHaojian Wu // CHECK-NEXT:|   |     |-RecoveryExpr {{.*}} '<dependent type>' contains-errors
29*733edf97SHaojian Wu // CHECK-NEXT:|   |     | `-UnresolvedLookupExpr {{.*}} 'bar'
30*733edf97SHaojian Wu // CHECK-NEXT:|   |     `-RecoveryExpr {{.*}} '<dependent type>' contains-errors
31*733edf97SHaojian Wu // CHECK-NEXT:|   |       `-UnresolvedLookupExpr {{.*}} 'baz'
32*733edf97SHaojian Wu int c = &(bar() + baz()) * 10;
33*733edf97SHaojian Wu 
34*733edf97SHaojian Wu // Errors flag propagates even when type is not dependent anymore.
35*733edf97SHaojian Wu // CHECK:     |-VarDecl {{.*}} d
36*733edf97SHaojian Wu // CHECK-NEXT:| `-CXXStaticCastExpr {{.*}} 'int' contains-errors
37*733edf97SHaojian Wu // CHECK-NEXT:|   `-BinaryOperator {{.*}} '<dependent type>' contains-errors '+'
38*733edf97SHaojian Wu // CHECK-NEXT:|     |-RecoveryExpr {{.*}} '<dependent type>' contains-errors
39*733edf97SHaojian Wu // CHECK-NEXT:|     | `-UnresolvedLookupExpr {{.*}} 'bar'
40*733edf97SHaojian Wu // CHECK-NEXT:|     `-IntegerLiteral {{.*}} 1
41*733edf97SHaojian Wu int d = static_cast<int>(bar() + 1);
42*733edf97SHaojian Wu 
43*733edf97SHaojian Wu // FIXME: store initializer even when 'auto' could not be deduced.
44*733edf97SHaojian Wu // Expressions with errors currently do not keep initializers around.
45*733edf97SHaojian Wu // CHECK:     `-VarDecl {{.*}} invalid e 'auto'
46*733edf97SHaojian Wu auto e = bar();
47