[cfe-commits] r123385 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp

Douglas Gregor dgregor at apple.com
Thu Jan 13 10:47:47 PST 2011


Author: dgregor
Date: Thu Jan 13 12:47:47 2011
New Revision: 123385

URL: http://llvm.org/viewvc/llvm-project?rev=123385&view=rev
Log:
Only apply the parameter pack matching of C++0x [temp.arg.template]p3
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.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=123385&r1=123384&r2=123385&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Jan 13 12:47:47 2011
@@ -3801,7 +3801,8 @@
   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,

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp?rev=123385&r1=123384&r2=123385&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp Thu Jan 13 12:47:47 2011
@@ -25,3 +25,19 @@
 
 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...>) {}
+}





More information about the cfe-commits mailing list