argument. As part of this, be more careful when determining if there
are any parameter packs that cannot be expanded.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122776
91177308-0d34-0410-b5e6-
96231b3b80d8
continue;
}
- // We can have a pack expansion of any of the above.
+ // We can have a pack expansion of any of the bullets below.
if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(ArgExpr))
ArgExpr = Expansion->getPattern();
// If we don't have a template argument at this depth/index, then we
// cannot expand the pack expansion. Make a note of this, but we still
// want to check any parameter packs we *do* have arguments for.
- if (!TemplateArgs.hasTemplateArgument(Depth, Index)) {
+ if (Depth >= TemplateArgs.getNumLevels() ||
+ !TemplateArgs.hasTemplateArgument(Depth, Index)) {
ShouldExpand = false;
continue;
}
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern,
SourceLocation EllipsisLoc) {
switch (Pattern.getArgument().getKind()) {
- case TemplateArgument::Expression:
- // FIXME: We should be able to handle this now!
+ case TemplateArgument::Expression: {
+ ExprResult Result
+ = getSema().ActOnPackExpansion(Pattern.getSourceExpression(),
+ EllipsisLoc);
+ if (Result.isInvalid())
+ return TemplateArgumentLoc();
+
+ return TemplateArgumentLoc(Result.get(), Result.get());
+ }
case TemplateArgument::Template:
- llvm_unreachable("Unsupported pack expansion of expressions/templates");
+ llvm_unreachable("Unsupported pack expansion of templates");
case TemplateArgument::Null:
case TemplateArgument::Integral:
--- /dev/null
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<typename T, T ...Values> struct value_tuple {};
+
+template<typename T>
+struct X0 {
+ template<T ...Values>
+ void f(value_tuple<T, Values...> * = 0);
+};
+
+void test_X0() {
+ X0<int>().f<1, 2, 3, 4, 5>();
+}
// FIXME: Test for unexpanded parameter packs in each of the statements.
// Test unexpanded parameter packs in partial specializations.
-
template<typename ...Types>
struct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}}