aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-05 15:48:55 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-05 15:48:55 +0000
commit61c4d28e36cd3f1be392cb77f07436d1fa6b0f9f (patch)
tree89f1f1bc62bd5e77e02ef2206ec4b308599e33c0 /lib/Sema/SemaTemplateInstantiate.cpp
parent07fa2fa8b9a0f7982a31e12f4164550d004543ae (diff)
Implement support for template template parameter packs, e.g.,
template<template<class> class ...Metafunctions> struct apply_to_each; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 5d724f3b70..a256537068 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -697,9 +697,22 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
TTP->getPosition()))
return D;
- // FIXME: Variadic templates index substitution.
- TemplateName Template
- = TemplateArgs(TTP->getDepth(), TTP->getPosition()).getAsTemplate();
+ TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
+
+ if (TTP->isParameterPack()) {
+ assert(Arg.getKind() == TemplateArgument::Pack &&
+ "Missing argument pack");
+
+ if (getSema().ArgumentPackSubstitutionIndex == -1) {
+ // FIXME: Variadic templates fun case.
+ getSema().Diag(Loc, diag::err_pack_expansion_mismatch_unsupported);
+ return 0;
+ }
+
+ Arg = Arg.pack_begin()[getSema().ArgumentPackSubstitutionIndex];
+ }
+
+ TemplateName Template = Arg.getAsTemplate();
assert(!Template.isNull() && Template.getAsTemplateDecl() &&
"Wrong kind of template template argument");
return Template.getAsTemplateDecl();