1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 template<int N> void f0(int (&array)[N]);
4
5 // Simple function template specialization (using overloading)
6 template<> void f0(int (&array)[1]);
7
test_f0()8 void test_f0() {
9 int iarr1[1];
10 f0(iarr1);
11 }
12
13 // Function template specialization where there are no matches
14 template<> void f0(char (&array)[1]); // expected-error{{no function template matches}}
f0(int (& array)[2])15 template<> void f0<2>(int (&array)[2]) { }
16
17 // Function template specialization that requires partial ordering
18 template<typename T, int N> void f1(T (&array)[N]); // expected-note{{matches}}
19 template<int N> void f1(int (&array)[N]); // expected-note{{matches}}
20
21 template<> void f1(float (&array)[1]);
22 template<> void f1(int (&array)[1]);
23
24 // Function template specialization that results in an ambiguity
25 template<typename T> void f1(T (&array)[17]); // expected-note{{matches}}
26 template<> void f1(int (&array)[17]); // expected-error{{ambiguous}}
27
28 // Resolving that ambiguity with explicitly-specified template arguments.
29 template<int N> void f2(double (&array)[N]);
30 template<typename T> void f2(T (&array)[42]);
31
32 template<> void f2<double>(double (&array)[42]);
33 template<> void f2<42>(double (&array)[42]);
34
35 void f2<25>(double (&array)[25]); // expected-error{{specialization}}
36
37 // PR5833
38 namespace PR5833 {
39 template <typename T> bool f0(T &t1);
40 template <> bool f0<float>(float &t1);
41 }
f0(float & t1)42 template <> bool PR5833::f0<float>(float &t1) {}
43
44 // PR8295
45 namespace PR8295 {
f(T t)46 template <typename T> void f(T t) {}
f(T * t)47 template <typename T> void f<T*>(T* t) {} // expected-error{{function template partial specialization is not allowed}}
48 }
49