================
@@ -13840,8 +13839,15 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr
*Init, bool DirectInit) {
return;
}
- if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
+ if (DeduceVariableDeclarationType(VDecl, DirectInit, Init)) {
+ assert(VDecl->isInvalidDecl() &&
+ "decl should be invalidated when deduce fails");
+ if (auto *RecoveryExpr =
+ CreateRecoveryExpr(Init->getBeginLoc(), Init->getEndLoc(),
{Init})
+ .get())
+ VDecl->setInit(RecoveryExpr);
----------------
zyn0217 wrote:
I wonder if we should move these to the place where the deduction first failed.
That way we will not have to ensure the error recovery for every callers. WDYT?
https://github.com/llvm/llvm-project/pull/173546
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits