1 // RUN: %clang_cc1 -std=c++11 -verify %s 2 3 template<typename ...T> struct X {}; 4 5 template<typename T, typename U> struct P {}; 6 7 namespace Nested { 8 template<typename ...T> int f1(X<T, T...>... a); // expected-note +{{conflicting types for parameter 'T'}} 9 template<typename ...T> int f2(P<X<T...>, T> ...a); // expected-note +{{conflicting types for parameter 'T'}} 10 11 int a1 = f1(X<int, int, double>(), X<double, int, double>()); 12 int a2 = f1(X<int, int>()); 13 int a3 = f1(X<int>(), X<double>()); // expected-error {{no matching}} 14 int a4 = f1(X<int, int>(), X<int>()); // expected-error {{no matching}} 15 int a5 = f1(X<int>(), X<int, int>()); // expected-error {{no matching}} 16 int a6 = f1(X<int, int, int>(), X<int, int, int>(), X<int, int, int, int>()); // expected-error {{no matching}} 17 18 int b1 = f2(P<X<int, double>, int>(), P<X<int, double>, double>()); 19 int b2 = f2(P<X<int, double>, int>(), P<X<int, double>, double>(), P<X<int, double>, char>()); // expected-error {{no matching}} 20 } 21 22 namespace PR14841 { 23 template<typename T, typename U> struct A {}; 24 template<typename ...Ts> void f(A<Ts...>); // expected-note {{substitution failure [with Ts = <char, short, int>]: too many template arg}} 25 g(A<char,short> a)26 void g(A<char, short> a) { 27 f(a); 28 f<char>(a); 29 f<char, short>(a); 30 f<char, short, int>(a); // expected-error {{no matching function}} 31 } 32 } 33 34 namespace RetainExprPacks { 35 int f(int a, int b, int c); 36 template<typename ...Ts> struct X {}; 37 template<typename ...Ts> int g(X<Ts...>, decltype(f(Ts()...))); 38 int n = g<int, int>(X<int, int, int>(), 0); 39 } 40 41 namespace PR14615 { 42 namespace comment0 { 43 template <class A, class...> struct X {}; 44 template <class... B> struct X<int, B...> { 45 typedef int type; 46 struct valid {}; 47 }; 48 template <typename A, typename... B, typename T = X<A, B...>, 49 typename = typename T::valid> 50 typename T::type check(int); 51 int i = check<int, char>(1); 52 } 53 54 namespace comment2 { 55 template <class...> struct X; 56 template <typename... B, typename X<B...>::type I = 0> 57 char check(B...); // expected-note {{undefined template 'PR14615::comment2::X<char, int>'}} f()58 void f() { check<char>(1, 2); } // expected-error {{no matching function}} 59 } 60 61 namespace comment3 { 62 template <class...> struct X; 63 template <typename... B, typename X<B...>::type I = (typename X<B...>::type)0> 64 char check(B...); // expected-note {{undefined template 'PR14615::comment3::X<char, int>'}} f()65 void f() { check<char>(1, 2); } // expected-error {{no matching function}} 66 } 67 } 68