diff --git a/clang/lib/3C/CastPlacement.cpp b/clang/lib/3C/CastPlacement.cpp index 3f88f366474a..f23237381b34 100644 --- a/clang/lib/3C/CastPlacement.cpp +++ b/clang/lib/3C/CastPlacement.cpp @@ -181,7 +181,8 @@ void CastPlacementVisitor::surroundByCast(ConstraintVariable *Dst, // If E is already a cast expression, we will try to rewrite the cast instead // of adding a new expression. - if (auto *CE = dyn_cast(E->IgnoreParens())) { + if (isa(E->IgnoreParens()) && CastKind == CAST_TO_WILD) { + auto *CE = cast(E->IgnoreParens()); SourceRange CastTypeRange(CE->getLParenLoc(), CE->getRParenLoc()); assert("Cast expected to start with '('" && !CastStrs.first.empty() && CastStrs.first[0] == '(');