diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 1d0896f585fb4..e362ec595a3bb 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -517,7 +517,10 @@ Improvements to Clang's diagnostics - Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about overlapping and non-overlapping ranges involving character literals and floating-point literals. The warning message for non-overlapping cases has also been improved (#GH13473). - + +- Fixed a duplicate diagnostic when performing typo correction on function template + calls with explicit template arguments. (#GH139226) + Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 2ba69c87d95e3..7940340064eda 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -523,6 +523,9 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS, if (Found.isAmbiguous()) { Found.clear(); } else if (!Found.empty()) { + // Do not erase the typo-corrected result to avoid duplicated + // diagnostics. + AllowFunctionTemplatesInLookup = true; Found.setLookupName(Corrected.getCorrection()); if (LookupCtx) { std::string CorrectedStr(Corrected.getAsString(getLangOpts())); diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp index e3599db18350b..3633ef1c293e2 100644 --- a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp +++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp @@ -98,3 +98,16 @@ namespace PR11856 { } } } + +namespace GH139226 { + +struct Foo { + template void LookupWithID(); // expected-note {{declared here}} +}; + +void test(Foo &f) { + f.LookupWithId(); + // expected-error@-1 {{did you mean 'LookupWithID'}} +} + +}