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