Implement support for non-type template parameter packs whose type is
a pack expansion, e.g., the parameter pack Values in:
template<typename ...Types>
struct Outer {
template<Types ...Values>
struct Inner;
};
This new implementation approach introduces the notion of an
"expanded" non-type template parameter pack, for which we have already
expanded the types of the parameter pack (to, say, "int*, float*",
for Outer<int*, float*>) but have not yet expanded the values. Aside
from creating these expanded non-type template parameter packs, this
patch updates template argument checking and non-type template
parameter pack instantiation to make use of the appropriate types in
the parameter pack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123845 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 812c633..fc48039 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1705,6 +1705,7 @@
DeducedTemplateArgument Arg,
NamedDecl *Template,
QualType NTTPType,
+ unsigned ArgumentPackIndex,
TemplateDeductionInfo &Info,
bool InFunctionTemplate,
llvm::SmallVectorImpl<TemplateArgument> &Output) {
@@ -1721,8 +1722,8 @@
DeducedTemplateArgument InnerArg(*PA);
InnerArg.setDeducedFromArrayBound(Arg.wasDeducedFromArrayBound());
if (ConvertDeducedTemplateArgument(S, Param, InnerArg, Template,
- NTTPType, Info,
- InFunctionTemplate, Output))
+ NTTPType, PackedArgsBuilder.size(),
+ Info, InFunctionTemplate, Output))
return true;
// Move the converted template argument into our argument pack.
@@ -1748,6 +1749,7 @@
Template,
Template->getLocation(),
Template->getSourceRange().getEnd(),
+ ArgumentPackIndex,
Output,
InFunctionTemplate
? (Arg.wasDeducedFromArrayBound()
@@ -1810,7 +1812,7 @@
}
if (ConvertDeducedTemplateArgument(S, Param, Deduced[I],
- Partial, NTTPType, Info, false,
+ Partial, NTTPType, 0, Info, false,
Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
@@ -2160,7 +2162,7 @@
}
if (ConvertDeducedTemplateArgument(*this, Param, Deduced[I],
- FunctionTemplate, NTTPType, Info,
+ FunctionTemplate, NTTPType, 0, Info,
true, Builder)) {
Info.Param = makeTemplateParameter(Param);
// FIXME: These template arguments are temporary. Free them!
@@ -2212,7 +2214,7 @@
FunctionTemplate,
FunctionTemplate->getLocation(),
FunctionTemplate->getSourceRange().getEnd(),
- Builder,
+ 0, Builder,
CTAK_Deduced)) {
Info.Param = makeTemplateParameter(
const_cast<NamedDecl *>(TemplateParams->getParam(I)));