PR21536: Fix a corner case where we'd get confused by a pack expanding into the

penultimate parameter of a template parameter list, where the last parameter is
itself a pack, and build a bogus empty final pack argument.

llvm-svn: 221748
This commit is contained in:
Richard Smith 2014-11-12 01:43:45 +00:00
parent f44dbda542
commit d8a52a7831
2 changed files with 18 additions and 2 deletions

View File

@ -3749,7 +3749,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
}
// Push the argument pack onto the list of converted arguments.
if (InFinalParameterPack) {
if (InFinalParameterPack && !ArgumentPack.empty()) {
Converted.push_back(
TemplateArgument::CreatePackCopy(Context,
ArgumentPack.data(),

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// Template argument deduction with template template parameters.
template<typename T, template<T> class A>
@ -162,3 +162,19 @@ namespace test14 {
foo(a);
}
}
namespace PR21536 {
template<typename ...T> struct X;
template<typename A, typename ...B> struct S {
static_assert(sizeof...(B) == 1, "");
void f() {
using T = A;
using T = int;
using U = X<B...>;
using U = X<int>;
}
};
template<typename ...T> void f(S<T...>);
void g() { f(S<int, int>()); }
}