summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
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
commit84a6a0a3ce7d45a5a948e79f1a48f9fbf236a481 (patch)
treeae60112fcdd57b2f16f2f749469c69b21998dc3b /clang/lib/Sema
parentbf5fe47b128f16ad601204763442af72fe0c39c0 (diff)
downloadbcm5719-llvm-84a6a0a3ce7d45a5a948e79f1a48f9fbf236a481.tar.gz
bcm5719-llvm-84a6a0a3ce7d45a5a948e79f1a48f9fbf236a481.zip
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>. llvm-svn: 126749
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp74
1 files changed, 34 insertions, 40 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index fbb72465335..a710f94436b 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud