]> granicus.if.org Git - clang/commitdiff
Merging r221748:
authorTom Stellard <thomas.stellard@amd.com>
Mon, 8 Dec 2014 23:38:45 +0000 (23:38 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 8 Dec 2014 23:38:45 +0000 (23:38 +0000)
------------------------------------------------------------------------
r221748 | richard-llvm | 2014-11-11 20:43:45 -0500 (Tue, 11 Nov 2014) | 4 lines

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.

------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_35@223718 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/deduction.cpp

index 63581a44dbe5b365004bec3a552bc8b5e6279f36..5596a0162b70e5c27f65203cfebe6b26ece1e704 100644 (file)
@@ -3746,7 +3746,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(),
index aecb5ee7c8b3dca59ca546140c7b2e2a0d247a41..c089573a9c0fe6fd331a8bfc730e4b64bac022c9 100644 (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>()); }
+}