Skip to content
Snippets Groups Projects
Commit 5f7701a4 authored by Kaelyn Takata's avatar Kaelyn Takata
Browse files

Try typo correction on all initialization arguments and be less

pessimistic about when to do so.

This also fixes PR21905 as the initialization argument was no longer
viewed as being type dependent due to the TypoExpr being type-cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224386 91177308-0d34-0410-b5e6-96231b3b80d8
parent b2c6c4fe
No related branches found
No related tags found
No related merge requests found
...@@ -8806,12 +8806,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, ...@@ -8806,12 +8806,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
Args = MultiExprArg(CXXDirectInit->getExprs(), Args = MultiExprArg(CXXDirectInit->getExprs(),
CXXDirectInit->getNumExprs()); CXXDirectInit->getNumExprs());
   
// Try to correct any TypoExprs if there might be some in the initialization // Try to correct any TypoExprs in the initialization arguments.
// arguments (TypoExprs are marked as type-dependent). for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
// TODO: Handle typo correction when there's more than one argument?
if (Args.size() == 1 && Expr::hasAnyTypeDependentArguments(Args)) {
ExprResult Res = ExprResult Res =
CorrectDelayedTyposInExpr(Args[0], [this, Entity, Kind](Expr *E) { CorrectDelayedTyposInExpr(Args[Idx], [this, Entity, Kind](Expr *E) {
InitializationSequence Init(*this, Entity, Kind, MultiExprArg(E)); InitializationSequence Init(*this, Entity, Kind, MultiExprArg(E));
return Init.Failed() ? ExprError() : E; return Init.Failed() ? ExprError() : E;
}); });
...@@ -8819,8 +8817,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, ...@@ -8819,8 +8817,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
VDecl->setInvalidDecl(); VDecl->setInvalidDecl();
return; return;
} }
if (Res.get() != Args[0]) if (Res.get() != Args[Idx])
Args[0] = Res.get(); Args[Idx] = Res.get();
} }
   
InitializationSequence InitSeq(*this, Entity, Kind, Args); InitializationSequence InitSeq(*this, Entity, Kind, Args);
......
...@@ -143,3 +143,7 @@ void test() { ...@@ -143,3 +143,7 @@ void test() {
int x = variableX.getX(); int x = variableX.getX();
} }
} }
namespace PR21905 {
int (*a) () = (void)Z; // expected-error-re {{use of undeclared identifier 'Z'{{$}}}}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment