Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -8015,7 +8015,8 @@ /// deduction-guide declaration. bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, - ParsedTemplateTy *Template = nullptr); + ParsedTemplateTy *Template = nullptr, + bool AllowTypoCorrection = true); bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Index: clang/lib/Parse/ParseTentative.cpp =================================================================== --- clang/lib/Parse/ParseTentative.cpp +++ clang/lib/Parse/ParseTentative.cpp @@ -13,6 +13,7 @@ #include "clang/Parse/Parser.h" #include "clang/Parse/ParseDiagnostic.h" +#include "clang/Parse/RAIIObjectsForParser.h" #include "clang/Sema/ParsedTemplate.h" using namespace clang; @@ -65,6 +66,7 @@ case tok::identifier: { if (DisambiguatingWithExpression) { RevertingTentativeParsingAction TPA(*this); + ParsingDeclSpec PDS(*this); // Parse the C++ scope specifier. CXXScopeSpec SS; ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, @@ -75,7 +77,9 @@ case tok::identifier: { IdentifierInfo *II = Tok.getIdentifierInfo(); bool isDeductionGuide = - Actions.isDeductionGuideName(getCurScope(), *II, Tok.getLocation()); + Actions.isDeductionGuideName(getCurScope(), *II, Tok.getLocation(), + /*Template=*/nullptr, + /*AllowTypoCorrection=*/false); if (Actions.isCurrentClassName(*II, getCurScope(), &SS) || isDeductionGuide) { if (isConstructorDeclarator(/*Unqualified=*/SS.isEmpty(), @@ -87,6 +91,8 @@ } case tok::kw_operator: return true; + case tok::tilde: // Check if this is a dtor. + return true; case tok::annot_cxxscope: // Check if this is a dtor. if (NextToken().is(tok::tilde)) return true; @@ -1370,6 +1376,7 @@ // a missing 'typename' keyword. Don't use TryAnnotateName in this case, // since it will annotate as a primary expression, and we want to use the // "missing 'typename'" logic. + SuppressAccessChecks SAC(*this); if (TryAnnotateTypeOrScopeToken(AllowImplicitTypename)) return TPResult::Error; // If annotation failed, assume it's a non-type. Index: clang/lib/Parse/Parser.cpp =================================================================== --- clang/lib/Parse/Parser.cpp +++ clang/lib/Parse/Parser.cpp @@ -707,8 +707,7 @@ // Late template parsing can begin. Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this); - if (!PP.isIncrementalProcessingEnabled()) - Actions.ActOnEndOfTranslationUnit(); + Actions.ActOnEndOfTranslationUnit(); //else don't tell Sema that we ended parsing: more input might come. return true; Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -315,7 +315,7 @@ bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, - ParsedTemplateTy *Template) { + ParsedTemplateTy *Template, bool AllowTypoCorrection /*=true*/) { CXXScopeSpec SS; bool MemberOfUnknownSpecialization = false; @@ -325,7 +325,9 @@ LookupResult R(*this, DeclarationName(&Name), NameLoc, LookupOrdinaryName); if (LookupTemplateName(R, S, SS, /*ObjectType*/ QualType(), /*EnteringContext*/ false, - MemberOfUnknownSpecialization)) + MemberOfUnknownSpecialization, + /*RequiredTemplate=*/SourceLocation(), + /*ATK=*/nullptr, AllowTypoCorrection)) return false; if (R.empty()) return false; Index: clang/test/Interpreter/disambiguate-decl-stmt.cpp =================================================================== --- clang/test/Interpreter/disambiguate-decl-stmt.cpp +++ clang/test/Interpreter/disambiguate-decl-stmt.cpp @@ -9,6 +9,23 @@ // Decls which are hard to disambiguate +// Typo correction. +template struct _List_iterator; +struct S4 { struct const_iterator {}; }; +class AddressRanges { using Collection = S4; Collection::const_iterator insert(); }; +AddressRanges::Collection::const_iterator AddressRanges::insert() { return {}; } + +// Access control. +class C4 { using Int = int; public: Int get(); }; +C4::Int C4::get() { return {}; } + +class C2 { class U { U();}; }; +C2::U::U() {} + +struct S3 { ~S3(); }; +S3::~S3() {} + + // Operators. struct S1 { operator int(); }; S1::operator int() { return 0; }