Shih-wei Liao | ea28516 | 2010-06-04 12:34:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | template<typename T> |
| 3 | int &f0(T); |
| 4 | |
| 5 | template<typename T> |
| 6 | float &f0(T*); |
| 7 | |
| 8 | void test_f0(int i, int *ip) { |
| 9 | int &ir = f0(i); |
| 10 | float &fr = f0(ip); |
| 11 | } |
| 12 | |
| 13 | template<typename T, typename U> |
| 14 | int &f1(T, U); |
| 15 | |
| 16 | template<typename T> |
| 17 | float &f1(T, T); |
| 18 | |
| 19 | void test_f1(int i, float f) { |
| 20 | int &ir = f1(i, f); |
| 21 | float &fr1 = f1(i, i); |
| 22 | float &fr2 = f1(f, f); |
| 23 | } |
| 24 | |
| 25 | template<typename T, typename U> |
| 26 | struct A { }; |
| 27 | |
| 28 | template<typename T> |
| 29 | int &f2(T); |
| 30 | |
| 31 | template<typename T, typename U> |
| 32 | float &f2(A<T, U>); |
| 33 | |
| 34 | template<typename T> |
| 35 | double &f2(A<T, T>); |
| 36 | |
| 37 | void test_f2(int i, A<int, float> aif, A<int, int> aii) { |
| 38 | int &ir = f2(i); |
| 39 | float &fr = f2(aif); |
| 40 | double &dr = f2(aii); |
| 41 | } |
| 42 | |
| 43 | template<typename T, typename U> |
| 44 | int &f3(T*, U); // expected-note{{candidate}} |
| 45 | |
| 46 | template<typename T, typename U> |
| 47 | float &f3(T, U*); // expected-note{{candidate}} |
| 48 | |
| 49 | void test_f3(int i, int *ip, float *fp) { |
| 50 | int &ir = f3(ip, i); |
| 51 | float &fr = f3(i, fp); |
| 52 | f3(ip, ip); // expected-error{{ambiguous}} |
| 53 | } |
| 54 | |
| 55 | template<typename T> |
| 56 | int &f4(T&); |
| 57 | |
| 58 | template<typename T> |
| 59 | float &f4(const T&); |
| 60 | |
| 61 | void test_f4(int i, const int ic) { |
| 62 | int &ir1 = f4(i); |
| 63 | float &fr1 = f4(ic); |
| 64 | } |
| 65 | |
| 66 | template<typename T, typename U> |
| 67 | int &f5(T&, const U&); // expected-note{{candidate}} |
| 68 | |
| 69 | template<typename T, typename U> |
| 70 | float &f5(const T&, U&); // expected-note{{candidate}} |
| 71 | |
| 72 | void test_f5(int i, const int ic) { |
| 73 | f5(i, i); // expected-error{{ambiguous}} |
| 74 | } |
| 75 | |
| 76 | template<typename T, typename U> |
| 77 | int &f6(T&, U&); |
| 78 | |
| 79 | template<typename T, typename U> |
| 80 | float &f6(const T&, U&); |
| 81 | |
| 82 | void test_f6(int i, const int ic) { |
| 83 | int &ir = f6(i, i); |
| 84 | float &fr = f6(ic, ic); |
| 85 | } |
| 86 | |
| 87 | struct CrazyFun { |
| 88 | template<typename T, typename U> operator A<T, U>(); |
| 89 | template<typename T> operator A<T, T>(); |
| 90 | }; |
| 91 | |
| 92 | void fun(CrazyFun cf) { |
| 93 | A<int, float> aif = cf; |
| 94 | A<int, int> aii = cf; |
| 95 | } |