diff --git a/interpreter/cling/lib/Utils/ParserStateRAII.cpp b/interpreter/cling/lib/Utils/ParserStateRAII.cpp index 60a69024cd253..a3f6e0f9a6709 100644 --- a/interpreter/cling/lib/Utils/ParserStateRAII.cpp +++ b/interpreter/cling/lib/Utils/ParserStateRAII.cpp @@ -29,7 +29,13 @@ cling::ParserStateRAII::ParserStateRAII(Parser& p) OldInNonInstantiationSFINAEContext(P->getActions() .InNonInstantiationSFINAEContext) { + // Set to defaults, reset to previous values by ~ParserStateRAII(). OldTemplateIds.swap(P->TemplateIds); + P->ParenCount = 0; + P->BracketCount = 0; + P->BraceCount = 0; + P->TemplateParameterDepth = 0; + P->getActions().InNonInstantiationSFINAEContext = false; } cling::ParserStateRAII::~ParserStateRAII() { diff --git a/interpreter/llvm/src/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp b/interpreter/llvm/src/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp index 1d9ceb98a425a..5b80bb9018494 100644 --- a/interpreter/llvm/src/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/interpreter/llvm/src/tools/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -111,6 +111,10 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS, // into that class template definition. QualType Injected = ClassTemplate->getInjectedClassNameSpecialization(); + + // Injected might not be canonical + Injected = Injected.getCanonicalType(); + if (Context.hasSameType(Injected, ContextType)) return ClassTemplate->getTemplatedDecl();