1// RUN: %clang_cc1 -fsyntax-only -verify %s
2template<typename T>
3int &f0(T);
4
5template<typename T>
6float &f0(T*);
7
8void test_f0(int i, int *ip) {
9  int &ir = f0(i);
10  float &fr = f0(ip);
11}
12
13template<typename T, typename U>
14int &f1(T, U);
15
16template<typename T>
17float &f1(T, T);
18
19void 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
25template<typename T, typename U>
26struct A { };
27
28template<typename T>
29int &f2(T);
30
31template<typename T, typename U>
32float &f2(A<T, U>);
33
34template<typename T>
35double &f2(A<T, T>);
36
37void 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
43template<typename T, typename U>
44int &f3(T*, U); // expected-note{{candidate}}
45
46template<typename T, typename U>
47float &f3(T, U*); // expected-note{{candidate}}
48
49void 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
55template<typename T>
56int &f4(T&);
57
58template<typename T>
59float &f4(const T&);
60
61void test_f4(int i, const int ic) {
62  int &ir1 = f4(i);
63  float &fr1 = f4(ic);
64}
65
66template<typename T, typename U>
67int &f5(T&, const U&); // expected-note{{candidate}}
68
69template<typename T, typename U>
70float &f5(const T&, U&); // expected-note{{candidate}}
71
72void test_f5(int i, const int ic) {
73  f5(i, i); // expected-error{{ambiguous}}
74}
75
76template<typename T, typename U>
77int &f6(T&, U&);
78
79template<typename T, typename U>
80float &f6(const T&, U&);
81
82void test_f6(int i, const int ic) {
83  int &ir = f6(i, i);
84  float &fr = f6(ic, ic);
85}
86
87struct CrazyFun {
88  template<typename T, typename U> operator A<T, U>();
89  template<typename T> operator A<T, T>();
90};
91
92void fun(CrazyFun cf) {
93  A<int, float> aif = cf;
94  A<int, int> aii = cf;
95}
96