diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3744,7 +3744,8 @@ case NPC_NeverValueDependent: llvm_unreachable("Unexpected value dependent expression!"); case NPC_ValueDependentIsNull: - if (isTypeDependent() || getType()->isIntegralType(Ctx)) + if ((!containsErrors() && isTypeDependent()) || + getType()->isIntegralType(Ctx)) return NPCK_ZeroExpression; else return NPCK_NotNull; diff --git a/clang/test/AST/ast-dump-recovery.c b/clang/test/AST/ast-dump-recovery.c --- a/clang/test/AST/ast-dump-recovery.c +++ b/clang/test/AST/ast-dump-recovery.c @@ -39,3 +39,14 @@ // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a' 'const int' static int foo = a++; // verify no crash on local static var decl. } + +void test2() { + int* ptr; + // FIXME: the top-level expr should be a binary operator. + // CHECK: ImplicitCastExpr {{.*}} contains-errors + // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors lvalue + // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ptr' 'int *' + // CHECK-NEXT: `-RecoveryExpr {{.*}} + // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func' + ptr = some_func(); // should not crash +}