diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -2707,6 +2707,17 @@ return; } + // If the type is dependent, we won't do any other semantic analysis now. + if (Self.getASTContext().isDependenceAllowed() && + (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() || + SrcExpr.get()->isValueDependent())) { + assert((DestType->containsErrors() || SrcExpr.get()->containsErrors() || + SrcExpr.get()->containsErrors()) && + "should only occur in error-recovery path."); + assert(Kind == CK_Dependent); + return; + } + // Overloads are allowed with C extensions, so we need to support them. if (SrcExpr.get()->getType() == Self.Context.OverloadTy) { DeclAccessPair DAP; 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 @@ -81,4 +81,9 @@ // CHECK-NEXT: |-DeclRefExpr {{.*}} 'int *' lvalue // CHECK-NEXT: `-DeclRefExpr {{.*}} 'float' lvalue (ptr > f ? ptr : f); + + // CHECK: CStyleCastExpr {{.*}} 'float' contains-errors + // CHECK-NEXT: `-RecoveryExpr {{.*}} '' + // CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func' + (float)some_func(); } diff --git a/clang/test/Sema/error-dependence.c b/clang/test/Sema/error-dependence.c --- a/clang/test/Sema/error-dependence.c +++ b/clang/test/Sema/error-dependence.c @@ -6,6 +6,10 @@ // verify "assigning to 'int' from incompatible type ''" is // not emitted. s = call(); // expected-error {{too few arguments to function call}} + + // verify diagnostic "operand of type '' where arithmetic or + // pointer type is required" is not emitted. + (float)call(); // expected-error {{too few arguments to function call}} } void test2(int* ptr, float f) {