Tweak the checking of class template partial specialization arguments

to cope with parameter packs. This is a band-aid I will be
revisiting this section when I implement declaration matching
semantics for variadic templates.

llvm-svn: 122369
This commit is contained in:
Douglas Gregor 2010-12-21 22:27:23 +00:00
parent 2085a96513
commit cff2764a6e
1 changed files with 16 additions and 4 deletions

View File

@ -3937,16 +3937,27 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
// specialization is identical to the implicit argument list of
// the primary template. The caller may need to diagnostic this as
// an error per C++ [temp.class.spec]p9b3.
TemplateArgument MirrorArg = ArgList[I];
if (MirrorsPrimaryTemplate &&
MirrorArg.getKind() == TemplateArgument::Pack) {
if (MirrorArg.pack_size() == 1)
MirrorArg = *MirrorArg.pack_begin();
else
MirrorsPrimaryTemplate = false;
}
if (MirrorsPrimaryTemplate) {
if (TemplateTypeParmDecl *TTP
= dyn_cast<TemplateTypeParmDecl>(TemplateParams->getParam(I))) {
if (Context.getCanonicalType(Context.getTypeDeclType(TTP)) !=
Context.getCanonicalType(ArgList[I].getAsType()))
if (MirrorsPrimaryTemplate &&
!Context.hasSameType(Context.getTypeDeclType(TTP),
MirrorArg.getAsType()))
MirrorsPrimaryTemplate = false;
} else if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(
TemplateParams->getParam(I))) {
TemplateName Name = ArgList[I].getAsTemplate();
// FIXME: Variadic templates pack expansion/parameter pack
TemplateName Name = MirrorArg.getAsTemplate();
TemplateTemplateParmDecl *ArgDecl
= dyn_cast_or_null<TemplateTemplateParmDecl>(Name.getAsTemplateDecl());
if (!ArgDecl ||
@ -3964,6 +3975,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
Expr *ArgExpr = ArgList[I].getAsExpr();
if (!ArgExpr) {
// FIXME: Variadic templates pack expansion/parameter pack
MirrorsPrimaryTemplate = false;
continue;
}