summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-12-16 23:07:00 +0000
committerKaelyn Takata <rikka@google.com>2014-12-16 23:07:00 +0000
commit938204aa02977f2bd1e545f43f9304451193e74c (patch)
tree6cdd92c350ebd995a440394aec620b8a4b080fc5
parentbf22a4eaeed17e2db5a83dfd8a7bb78af7b2ea00 (diff)
downloadbcm5719-llvm-938204aa02977f2bd1e545f43f9304451193e74c.tar.gz
bcm5719-llvm-938204aa02977f2bd1e545f43f9304451193e74c.zip
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. llvm-svn: 224386
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
-rw-r--r--clang/test/SemaCXX/typo-correction-delayed.cpp4
2 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 298e4e705f6..d4b87ba615e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8806,12 +8806,10 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
Args = MultiExprArg(CXXDirectInit->getExprs(),
CXXDirectInit->getNumExprs());
- // Try to correct any TypoExprs if there might be some in the initialization
- // arguments (TypoExprs are marked as type-dependent).
- // TODO: Handle typo correction when there's more than one argument?
- if (Args.size() == 1 && Expr::hasAnyTypeDependentArguments(Args)) {
+ // Try to correct any TypoExprs in the initialization arguments.
+ for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
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));
return Init.Failed() ? ExprError() : E;
});
@@ -8819,8 +8817,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
VDecl->setInvalidDecl();
return;
}
- if (Res.get() != Args[0])
- Args[0] = Res.get();
+ if (Res.get() != Args[Idx])
+ Args[Idx] = Res.get();
}
InitializationSequence InitSeq(*this, Entity, Kind, Args);
diff --git a/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp
index c91fb6ca65e..a9bc91e0308 100644
--- a/clang/test/SemaCXX/typo-correction-delayed.cpp
+++ b/clang/test/SemaCXX/typo-correction-delayed.cpp
@@ -143,3 +143,7 @@ void test() {
int x = variableX.getX();
}
}
+
+namespace PR21905 {
+int (*a) () = (void)Z; // expected-error-re {{use of undeclared identifier 'Z'{{$}}}}
+}
OpenPOWER on IntegriCloud