diff options
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 3 |
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 1c324b8a02..ee3f8b5487 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -5256,8 +5256,6 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, TypeSourceInfo *InnerTSI = 0; QualType T = GetTypeFromParser(Ty, &InnerTSI); - NestedNameSpecifier *NNS - = static_cast<NestedNameSpecifier *>(SS.getScopeRep()); assert(isa<TemplateSpecializationType>(T) && "Expected a template specialization type"); @@ -5274,7 +5272,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, else Builder.push<TemplateSpecializationTypeLoc>(T).initialize(TemplateLoc); - T = Context.getElaboratedType(ETK_Typename, NNS, T); + /* Note: NNS already embedded in template specialization type T. */ + T = Context.getElaboratedType(ETK_Typename, /*NNS=*/0, T); ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T); TL.setKeywordLoc(TypenameLoc); TL.setQualifierRange(SS.getRange()); @@ -5289,7 +5288,10 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, DependentTemplateName *DTN = TST->getTemplateName().getAsDependentTemplateName(); assert(DTN && "dependent template has non-dependent name?"); - T = Context.getDependentTemplateSpecializationType(ETK_Typename, NNS, + assert(DTN->getQualifier() + == static_cast<NestedNameSpecifier*>(SS.getScopeRep())); + T = Context.getDependentTemplateSpecializationType(ETK_Typename, + DTN->getQualifier(), DTN->getIdentifier(), TST->getNumArgs(), TST->getArgs()); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index b3df9eb436..4d10fd030b 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1317,9 +1317,9 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: + // Note: NNSPrefix (if any) is included in ClsType + // (hence, no need to wrap ClsType in an elaborated type). ClsType = QualType(NNS->getAsType(), 0); - if (NNSPrefix) - ClsType = Context.getElaboratedType(ETK_None, NNSPrefix, ClsType); break; } } else { diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index a61768bcf4..1ff6d5335d 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -559,7 +559,8 @@ public: getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); if (T.isNull()) return QualType(); - return SemaRef.Context.getElaboratedType(Keyword, NNS, T); + // NOTE: NNS is already recorded in template specialization type T. + return SemaRef.Context.getElaboratedType(Keyword, /*NNS=*/0, T); } /// \brief Build a new typename type that refers to an identifier. |