diff options
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 0e1daea23c..3938978dfd 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2170,16 +2170,29 @@ Sema::ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS, QualType Sema::CheckTypenameType(NestedNameSpecifier *NNS, const IdentifierInfo &II, SourceRange Range) { - if (NNS->isDependent()) // FIXME: member of the current instantiation! - return Context.getTypenameType(NNS, &II); + CXXRecordDecl *CurrentInstantiation = 0; + if (NNS->isDependent()) { + CurrentInstantiation = getCurrentInstantiationOf(NNS); + + // If the nested-name-specifier does not refer to the current + // instantiation, then build a typename type. + if (!CurrentInstantiation) + return Context.getTypenameType(NNS, &II); + } - CXXScopeSpec SS; - SS.setScopeRep(NNS); - SS.setRange(Range); - if (RequireCompleteDeclContext(SS)) - return QualType(); + DeclContext *Ctx = 0; - DeclContext *Ctx = computeDeclContext(SS); + if (CurrentInstantiation) + Ctx = CurrentInstantiation; + else { + CXXScopeSpec SS; + SS.setScopeRep(NNS); + SS.setRange(Range); + if (RequireCompleteDeclContext(SS)) + return QualType(); + + Ctx = computeDeclContext(SS); + } assert(Ctx && "No declaration context?"); DeclarationName Name(&II); |