From cff2764a6eb8123557c98891384b975a6bdd4d6c Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 21 Dec 2010 22:27:23 +0000 Subject: [PATCH] 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 --- clang/lib/Sema/SemaTemplate.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index ca2a43b72955..661d26761df9 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -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(TemplateParams->getParam(I))) { - if (Context.getCanonicalType(Context.getTypeDeclType(TTP)) != - Context.getCanonicalType(ArgList[I].getAsType())) + = dyn_cast(TemplateParams->getParam(I))) { + if (MirrorsPrimaryTemplate && + !Context.hasSameType(Context.getTypeDeclType(TTP), + MirrorArg.getAsType())) MirrorsPrimaryTemplate = false; } else if (TemplateTemplateParmDecl *TTP = dyn_cast( 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(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; }