18fbe78f6SDaniel Dunbar // RUN: %clang_cc1 -fsyntax-only -verify %s
2ad3f2fcfSDouglas Gregor
3ad3f2fcfSDouglas Gregor template<typename T> struct A { };
4ad3f2fcfSDouglas Gregor
5ad3f2fcfSDouglas Gregor template<typename T> A<T> f0(T*);
6ad3f2fcfSDouglas Gregor
test_f0(int * ip,float const * cfp)7ad3f2fcfSDouglas Gregor void test_f0(int *ip, float const *cfp) {
8ad3f2fcfSDouglas Gregor A<int> a0 = f0(ip);
9ad3f2fcfSDouglas Gregor A<const float> a1 = f0(cfp);
10ad3f2fcfSDouglas Gregor }
11ad3f2fcfSDouglas Gregor
12705c900dSDouglas Gregor template<typename T> void f1(T*, int);
13705c900dSDouglas Gregor
test_f1(int * ip,float fv)14705c900dSDouglas Gregor void test_f1(int *ip, float fv) {
15705c900dSDouglas Gregor f1(ip, fv);
16705c900dSDouglas Gregor }
17705c900dSDouglas Gregor
1844ecdbdcSRichard Smith template<typename T> void f2(T*, T*); // expected-note {{candidate template ignored: could not match 'T *' against 'ConvToIntPtr'}} \
193626a5caSDouglas Gregor // expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'float')}}
20705c900dSDouglas Gregor
21705c900dSDouglas Gregor struct ConvToIntPtr {
22705c900dSDouglas Gregor operator int*() const;
23705c900dSDouglas Gregor };
24705c900dSDouglas Gregor
test_f2(int * ip,float * fp)25705c900dSDouglas Gregor void test_f2(int *ip, float *fp) {
26705c900dSDouglas Gregor f2(ip, ConvToIntPtr()); // expected-error{{no matching function}}
27705c900dSDouglas Gregor f2(ip, ip); // okay
28705c900dSDouglas Gregor f2(ip, fp); // expected-error{{no matching function}}
29705c900dSDouglas Gregor }
30*e750491fSDavid Blaikie
31*e750491fSDavid Blaikie namespace test3 {
32*e750491fSDavid Blaikie template<typename T>
33*e750491fSDavid Blaikie struct bar { };
34*e750491fSDavid Blaikie
35*e750491fSDavid Blaikie template<typename T>
36*e750491fSDavid Blaikie struct foo {
37*e750491fSDavid Blaikie operator bar<T>();
38*e750491fSDavid Blaikie };
39*e750491fSDavid Blaikie
40*e750491fSDavid Blaikie template<typename T>
func(bar<T>)41*e750491fSDavid Blaikie void func(bar<T>) { // expected-note {{candidate template ignored: could not match 'bar' against 'foo'}}
42*e750491fSDavid Blaikie }
43*e750491fSDavid Blaikie
test()44*e750491fSDavid Blaikie void test() {
45*e750491fSDavid Blaikie func(foo<int>()); // expected-error {{no matching function}}
46*e750491fSDavid Blaikie }
47*e750491fSDavid Blaikie }
48