aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-03-01 16:44:30 +0000
committerDouglas Gregor <dgregor@apple.com>2011-03-01 16:44:30 +0000
commitef24c4b85e354255240bbbc21772098e6c3f6ae8 (patch)
tree8633e6838bb18af4fb064b07f6fd7ea68ce03c63 /lib/Sema/SemaTemplate.cpp
parentbe38c5f5d8fa7c43c52fafddee054b8fe8c2b964 (diff)
When building a type for a typename specifier, check specifically for
a dependent template name rather than (indirectly and incorrectly) trying to determine whether we can compute a context for the nested-name-specifier. Fixes a GCC testsuite regression, <rdar://problem/9068589>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp74
1 files changed, 34 insertions, 40 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index fbb7246533..a710f94436 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -5950,62 +5950,56 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
translateTemplateArguments(TemplateArgsIn, TemplateArgs);
TemplateName Template = TemplateIn.get();
-
- if (computeDeclContext(SS, false)) {
- // If we can compute a declaration context, then the "typename"
- // keyword was superfluous. Just build an ElaboratedType to keep
- // track of the nested-name-specifier.
-
- QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
- if (T.isNull())
- return true;
+ if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
+ // Construct a dependent template specialization type.
+ assert(DTN && "dependent template has non-dependent name?");
+ assert(DTN->getQualifier()
+ == static_cast<NestedNameSpecifier*>(SS.getScopeRep()));
+ QualType T = Context.getDependentTemplateSpecializationType(ETK_Typename,
+ DTN->getQualifier(),
+ DTN->getIdentifier(),
+ TemplateArgs);
- // Provide source-location information for the template specialization
- // type.
+ // Create source-location information for this type.
TypeLocBuilder Builder;
- TemplateSpecializationTypeLoc SpecTL
- = Builder.push<TemplateSpecializationTypeLoc>(T);
-
- // FIXME: No place to set the location of the 'template' keyword!
+ DependentTemplateSpecializationTypeLoc SpecTL
+ = Builder.push<DependentTemplateSpecializationTypeLoc>(T);
SpecTL.setLAngleLoc(LAngleLoc);
SpecTL.setRAngleLoc(RAngleLoc);
- SpecTL.setTemplateNameLoc(TemplateNameLoc);
+ SpecTL.setKeywordLoc(TypenameLoc);
+ SpecTL.setNameLoc(TemplateNameLoc);
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo());
- T = Context.getElaboratedType(ETK_Typename, SS.getScopeRep(), T);
- ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
- TL.setKeywordLoc(TypenameLoc);
- TL.setQualifierLoc(SS.getWithLocInContext(Context));
-
- TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
- return CreateParsedType(T, TSI);
+ // FIXME: Nested-name-specifier source locations.
+ SpecTL.setQualifierRange(SS.getRange());
+ return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T));
}
- // Construct a dependent template specialization type.
- DependentTemplateName *DTN = Template.getAsDependentTemplateName();
- assert(DTN && "dependent template has non-dependent name?");
- assert(DTN->getQualifier()
- == static_cast<NestedNameSpecifier*>(SS.getScopeRep()));
- QualType T = Context.getDependentTemplateSpecializationType(ETK_Typename,
- DTN->getQualifier(),
- DTN->getIdentifier(),
- TemplateArgs);
+ QualType T = CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
+ if (T.isNull())
+ return true;
- // Create source-location information for this type.
+ // Provide source-location information for the template specialization
+ // type.
TypeLocBuilder Builder;
- DependentTemplateSpecializationTypeLoc SpecTL
- = Builder.push<DependentTemplateSpecializationTypeLoc>(T);
+ TemplateSpecializationTypeLoc SpecTL
+ = Builder.push<TemplateSpecializationTypeLoc>(T);
+
+ // FIXME: No place to set the location of the 'template' keyword!
SpecTL.setLAngleLoc(LAngleLoc);
SpecTL.setRAngleLoc(RAngleLoc);
- SpecTL.setKeywordLoc(TypenameLoc);
- SpecTL.setNameLoc(TemplateNameLoc);
+ SpecTL.setTemplateNameLoc(TemplateNameLoc);
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
SpecTL.setArgLocInfo(I, TemplateArgs[I].getLocInfo());
- // FIXME: Nested-name-specifier source locations.
- SpecTL.setQualifierRange(SS.getRange());
- return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T));
+ T = Context.getElaboratedType(ETK_Typename, SS.getScopeRep(), T);
+ ElaboratedTypeLoc TL = Builder.push<ElaboratedTypeLoc>(T);
+ TL.setKeywordLoc(TypenameLoc);
+ TL.setQualifierLoc(SS.getWithLocInContext(Context));
+
+ TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
+ return CreateParsedType(T, TSI);
}