blob: 90e38cc882fecca89621380550afd74a9e3a1f71 [file] [log] [blame]
Douglas Gregorb9aa6b22009-09-24 23:14:47 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3template<int N> void f0(int (&array)[N]);
4
5// Simple function template specialization (using overloading)
6template<> void f0(int (&array)[1]);
7
8void test_f0() {
9 int iarr1[1];
10 f0(iarr1);
11}
12
13// Function template specialization where there are no matches
14template<> void f0(char (&array)[1]); // expected-error{{no function template matches}}
Douglas Gregor0b60d9e2009-09-25 23:53:26 +000015template<> void f0<2>(int (&array)[2]) { }
Douglas Gregorb9aa6b22009-09-24 23:14:47 +000016
17// Function template specialization that requires partial ordering
18template<typename T, int N> void f1(T (&array)[N]); // expected-note{{matches}}
19template<int N> void f1(int (&array)[N]); // expected-note{{matches}}
20
21template<> void f1(float (&array)[1]);
22template<> void f1(int (&array)[1]);
23
24// Function template specialization that results in an ambiguity
25template<typename T> void f1(T (&array)[17]); // expected-note{{matches}}
26template<> void f1(int (&array)[17]); // expected-error{{ambiguous}}
Douglas Gregor0b60d9e2009-09-25 23:53:26 +000027
28// Resolving that ambiguity with explicitly-specified template arguments.
29template<int N> void f2(double (&array)[N]);
30template<typename T> void f2(T (&array)[42]);
31
32template<> void f2<double>(double (&array)[42]);
33template<> void f2<42>(double (&array)[42]);
34
35void f2<25>(double (&array)[25]); // expected-error{{specialization}}