diff options
author | Kaelyn Takata <rikka@google.com> | 2015-03-17 23:50:12 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2015-03-17 23:50:12 +0000 |
commit | 3587fff95e26410ca03963681ce809f017110563 (patch) | |
tree | b38eca31b8830f085173e71835f387c0f758c78a /clang/lib/Sema/SemaDecl.cpp | |
parent | c9d9610317a5f716fae167101818c729808568df (diff) | |
download | bcm5719-llvm-3587fff95e26410ca03963681ce809f017110563.tar.gz bcm5719-llvm-3587fff95e26410ca03963681ce809f017110563.zip |
Fix a crash when the size of an 'auto' is needed and its initalizer
contained a typo correction (the auto decl was being marked as dependent
unnecessarily, which triggered an assertion in cases where the size of
the type is needed).
llvm-svn: 232568
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 32e3924e35e..743c4ce4d14 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8688,6 +8688,20 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, // C++11 [decl.spec.auto]p6. Deduce the type which 'auto' stands in for. if (TypeMayContainAuto && VDecl->getType()->isUndeducedType()) { + // Attempt typo correction early so that the type of the init expression can + // be deduced based on the chosen correction:if the original init contains a + // TypoExpr. + ExprResult Res = CorrectDelayedTyposInExpr(Init); + if (!Res.isUsable()) { + RealDecl->setInvalidDecl(); + return; + } + if (Res.get() != Init) { + Init = Res.get(); + if (CXXDirectInit) + CXXDirectInit = dyn_cast<ParenListExpr>(Init); + } + Expr *DeduceInit = Init; // Initializer could be a C++ direct-initializer. Deduction only works if it // contains exactly one expression. |