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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122369 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index ca2a43b..661d267 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -3937,16 +3937,27 @@
// 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()))
+ = dyn_cast<TemplateTypeParmDecl>(TemplateParams->getParam(I))) {
+ 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 @@
Expr *ArgExpr = ArgList[I].getAsExpr();
if (!ArgExpr) {
+ // FIXME: Variadic templates pack expansion/parameter pack
MirrorsPrimaryTemplate = false;
continue;
}