aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-09-04 01:14:41 +0000
committerJohn McCall <rjmccall@apple.com>2009-09-04 01:14:41 +0000
commitf1bbbb49f06a7462476cd88166fccda5feb15cab (patch)
tree849b9006cad1a7c4dcd4cf03a4a7a5a96f15cc5e /lib/Sema/SemaTemplate.cpp
parent34374e6ce5710a91c478f69379220ff20c3e7f15 (diff)
Correctly handle elaborated template ids. Still not handled properly for friends.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80977 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 119e17f814..8eaa9fb397 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1121,7 +1121,9 @@ Sema::ActOnTemplateIdType(TemplateTy TemplateD, SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ASTTemplateArgsPtr TemplateArgsIn,
SourceLocation *TemplateArgLocs,
- SourceLocation RAngleLoc) {
+ SourceLocation RAngleLoc,
+ DeclSpec::TST TagSpec,
+ SourceLocation TagLoc) {
TemplateName Template = TemplateD.getAsVal<TemplateName>();
// Translate the parser's template argument list in our AST format.
@@ -1137,6 +1139,25 @@ Sema::ActOnTemplateIdType(TemplateTy TemplateD, SourceLocation TemplateLoc,
if (Result.isNull())
return true;
+ // If we were given a tag specifier, verify it.
+ if (TagSpec != DeclSpec::TST_unspecified) {
+ TagDecl::TagKind TagKind = TagDecl::getTagKindForTypeSpec(TagSpec);
+
+ if (const RecordType *T = Result->getAs<RecordType>()) {
+ RecordDecl *D = T->getDecl();
+
+ IdentifierInfo *Id = D->getIdentifier();
+ assert(Id && "templated class must have an identifier");
+
+ if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) {
+ Diag(TagLoc, diag::err_use_with_wrong_tag)
+ << Id
+ << CodeModificationHint::CreateReplacement(SourceRange(TagLoc),
+ D->getKindName());
+ }
+ }
+ }
+
return Result.getAsOpaquePtr();
}
@@ -2497,6 +2518,8 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
SourceLocation RAngleLoc,
AttributeList *Attr,
MultiTemplateParamsArg TemplateParameterLists) {
+ assert(TUK == TUK_Declaration || TUK == TUK_Definition);
+
// Find the class template we're specializing
TemplateName Name = TemplateD.getAsVal<TemplateName>();
ClassTemplateDecl *ClassTemplate