1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 template<class T
> void apply(T x
, void (*f
)(T
)) { f(x
); } // expected-note 2 {{candidate template ignored: deduced conflicting types for parameter 'T'}}\
5 // expected-note {{no overload of 'temp2' matching 'void (*)(int)'}}
7 template<class A
> void temp(A
);
9 // okay: deduce T=int from first argument, A=int during overload
13 // okay: deduce T=int from first and second arguments
16 // deduction failure: T=int from first, T=long from second
17 apply(0, &temp
<long>); // expected-error {{no matching function for call to 'apply'}}
24 // okay: deductions match
27 // deduction failure: deduced T=long from first argument, T=int from second
28 apply(0L, &over
); // expected-error {{no matching function for call to 'apply'}}
34 // deduce T=int from first arg, second arg is undeduced context,
35 // pick correct overload of 'over' during overload resolution for 'apply'
39 template<class A
, class B
> B
temp2(A
);
41 // deduce T=int from first arg, A=int B=void during overload resolution
44 apply(0, &temp2
<int>);
47 apply(0, &temp2
<long>); // expected-error {{no matching function for call to 'apply'}}
52 template<class T
> void invoke(void (*f
)(T
)) { f(T()); } // expected-note 6 {{couldn't infer template argument}} \
53 // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
55 template<class T
> void temp(T
);
57 // deduction failure: overload has template => undeduced context
58 invoke(&temp
); // expected-error {{no matching function for call to 'invoke'}}
59 invoke(&temp
<>); // expected-error {{no matching function for call to 'invoke'}}
61 // okay: full template-id
69 // okay: only one overload matches
76 // deduction failure: overload has multiple matches => undeduced context
77 invoke(&over
); // expected-error {{no matching function for call to 'invoke'}}
80 template<class A
, class B
> B
temp2(A
);
82 // deduction failure: overload has template => undeduced context
83 // (even though partial application temp2<int> could in theory
84 // let us infer T=int)
85 invoke(&temp2
); // expected-error {{no matching function for call to 'invoke'}}
86 invoke(&temp2
<>); // expected-error {{no matching function for call to 'invoke'}}
87 invoke(&temp2
<int>); // expected-error {{no matching function for call to 'invoke'}}
89 // okay: full template-id
90 invoke(&temp2
<int, void>);
93 invoke(&temp2
<int, int>); // expected-error {{no matching function for call to 'invoke'}}
97 namespace rdar8360106
{
98 template<typename R
, typename T
> void f0(R (*)(T
), T
);
99 template<typename R
, typename T
> void f1(R (&)(T
) , T
); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}}
100 template<typename R
, typename T
> void f2(R (* const&)(T
), T
); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}}
109 f1(&g
, 1); // expected-error{{no matching function for call to 'f1'}}
110 f2(g
, 1); // expected-error{{no matching function for call to 'f2'}}
117 int f(int, int, int);
120 float f(float, float);
122 template<typename R
, typename B1
, typename B2
, typename A1
, typename A2
>
123 R
& g(R (*)(B1
, B2
), A1
, A2
);
126 float &fr
= g(f
<int>, 1, 2);