]> granicus.if.org Git - clang/commitdiff
Only apply the parameter pack matching of C++0x [temp.arg.template]p3
authorDouglas Gregor <dgregor@apple.com>
Thu, 13 Jan 2011 18:47:47 +0000 (18:47 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 13 Jan 2011 18:47:47 +0000 (18:47 +0000)
when we're actually matching a template template argument to a
template template parameter. Otherwise, use strict matching.

Fixes <rdar://problem/8859985> clang++: variadics and out-of-line definitions.

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

lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp

index 08384ccef54f79f94a8a868fe1c7a684329e61eb..868458c2a98ce5f5b5118158abee0cb07895bcbe 100644 (file)
@@ -3801,7 +3801,8 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
   for (TemplateParameterList::iterator OldParm = Old->begin(),
                                     OldParmEnd = Old->end();
        OldParm != OldParmEnd; ++OldParm) {
-    if (!(*OldParm)->isTemplateParameterPack()) {
+    if (Kind != TPL_TemplateTemplateArgumentMatch ||
+        !(*OldParm)->isTemplateParameterPack()) {
       if (NewParm == NewParmEnd) {
         if (Complain)
           DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind,
index 3fc774cbfad0c64da20179e1bf5672bba1e9f1d4..989ff9f6d9f52717723b0572e21a71ce2d6f64b6 100644 (file)
@@ -25,3 +25,19 @@ template<int Values> struct X1nt; // expected-error{{non-type template parameter
 
 template<template<class T> class> class X1tt; // expected-note{{previous template template parameter declared here}}
 template<template<class T> class...> class X1tt; // expected-error{{template template parameter pack conflicts with previous template template parameter}}
+
+// Check for matching with out-of-line definitions
+namespace rdar8859985 {
+  template<typename ...> struct tuple { };
+  template<int ...> struct int_tuple { };
+
+  template<typename T>
+  struct X {
+    template<typename ...Args1, int ...Indices1>
+    X(tuple<Args1...>, int_tuple<Indices1...>);
+  };
+
+  template<typename T>
+  template<typename ...Args1, int ...Indices1>
+  X<T>::X(tuple<Args1...>, int_tuple<Indices1...>) {}
+}