diff options
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/function-overload-typo-crash.cpp | 12 |
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 2fa7b2515e..1e04ac734e 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1404,8 +1404,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions())); R.setLookupName(Corrected.getCorrection()); - if (!Corrected.isKeyword()) { - NamedDecl *ND = Corrected.getCorrectionDecl(); + if (NamedDecl *ND = Corrected.getCorrectionDecl()) { R.addDecl(ND); if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)) { if (SS.isEmpty()) diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 0ecd81400b..7d075db0c4 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -3744,6 +3744,8 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: I->second.setCorrectionDecl(TmpRes.getAsSingle<NamedDecl>()); + // FIXME: This sets the CorrectionDecl to NULL for overloaded functions. + // It would be nice to find the right one with overload resolution. ++I; break; } @@ -3835,7 +3837,6 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, // wasn't actually in scope. if (ED == 0 && Result.isKeyword()) return TypoCorrection(); - assert(Result.isResolved() && "correction has not been looked up"); // Record the correction for unqualified lookup. if (IsUnqualifiedLookup) UnqualifiedTyposCorrected[Typo] = Result; diff --git a/test/SemaCXX/function-overload-typo-crash.cpp b/test/SemaCXX/function-overload-typo-crash.cpp new file mode 100644 index 0000000000..0fea312a97 --- /dev/null +++ b/test/SemaCXX/function-overload-typo-crash.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR10283 +void min(); +void min(int); + +template <typename T> void max(T); + +void f() { + fin(); //expected-error {{use of undeclared identifier 'fin'; did you mean 'min'}} + fax(0); //expected-error {{use of undeclared identifier 'fax'; did you mean 'max'}} +} |