]> granicus.if.org Git - clang/commitdiff
PR21536: Fix a corner case where we'd get confused by a pack expanding into the
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Nov 2014 01:43:45 +0000 (01:43 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 12 Nov 2014 01:43:45 +0000 (01:43 +0000)
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/trunk@221748 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1bddfe218461a1aa9dd884c5e33fb06bacd5f975..50a4298333f46b4095e85ef65adc8fc3ee54fc73 100644 (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(),
index 59162b74cc6dbb67a37dca7d87e3753d299164fc..797f7f8261bb6c9fda3ffb829b9d52dbe1efe664 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>()); }
+}