r221748 - PR21536: Fix a corner case where we'd get confused by a pack expanding into the
Richard Smith
richard-llvm at metafoo.co.uk
Tue Nov 11 17:43:46 PST 2014
Author: rsmith
Date: Tue Nov 11 19:43:45 2014
New Revision: 221748
URL: http://llvm.org/viewvc/llvm-project?rev=221748&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=221748&r1=221747&r2=221748&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Nov 11 19:43:45 2014
@@ -3749,7 +3749,7 @@ bool Sema::CheckTemplateArgumentList(Tem
}
// Push the argument pack onto the list of converted arguments.
- if (InFinalParameterPack) {
+ if (InFinalParameterPack && !ArgumentPack.empty()) {
Converted.push_back(
TemplateArgument::CreatePackCopy(Context,
ArgumentPack.data(),
Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=221748&r1=221747&r2=221748&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Tue Nov 11 19:43:45 2014
@@ -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>()); }
+}
More information about the cfe-commits
mailing list