xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc void g();
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc void f(); // expected-note 9{{candidate function}}
5*f4a2713aSLionel Sambuc void f(int); // expected-note 9{{candidate function}}
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc template <class T>
8*f4a2713aSLionel Sambuc void t(T); // expected-note 3{{candidate function}} \
9*f4a2713aSLionel Sambuc            // expected-note 3{{candidate template ignored: could not match 'void' against 'int'}}
10*f4a2713aSLionel Sambuc template <class T>
11*f4a2713aSLionel Sambuc void t(T *); // expected-note 3{{candidate function}} \
12*f4a2713aSLionel Sambuc              // expected-note 3{{candidate template ignored: could not match 'void' against 'int'}}
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc template<class T> void u(T);
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc int main()
17*f4a2713aSLionel Sambuc {
18*f4a2713aSLionel Sambuc   { bool b = (void (&)(char))f; } // expected-error{{does not match required type}}
19*f4a2713aSLionel Sambuc   { bool b = (void (*)(char))f; } // expected-error{{does not match required type}}
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   { bool b = (void (&)(int))f; } //ok
22*f4a2713aSLionel Sambuc   { bool b = (void (*)(int))f; } //ok
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
25*f4a2713aSLionel Sambuc   { bool b = static_cast<void (*)(char)>(f); } // expected-error{{address of overloaded function}}
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc   { bool b = static_cast<void (&)(int)>(f); } //ok
28*f4a2713aSLionel Sambuc   { bool b = static_cast<void (*)(int)>(f); } //ok
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (&)(char)>(f); } // expected-error{{cannot resolve}}
32*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (*)(char)>(f); } // expected-error{{cannot resolve}}
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (*)(char)>(g); } //ok
35*f4a2713aSLionel Sambuc   { bool b = static_cast<void (*)(char)>(g); } // expected-error{{not allowed}}
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (&)(int)>(f); } // expected-error{{cannot resolve}}
38*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (*)(int)>(f); } // expected-error{{cannot resolve}}
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc   { bool b = (int (&)(char))t; } // expected-error{{does not match}}
41*f4a2713aSLionel Sambuc   { bool b = (int (*)(char))t; } // expected-error{{does not match}}
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc   { bool b = (void (&)(int))t; } //ok
44*f4a2713aSLionel Sambuc   { bool b = (void (*)(int))t; } //ok
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc   { bool b = static_cast<void (&)(char)>(t); } //ok
47*f4a2713aSLionel Sambuc   { bool b = static_cast<void (*)(char)>(t); } //ok
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc   { bool b = static_cast<void (&)(int)>(t); } //ok
50*f4a2713aSLionel Sambuc   { bool b = static_cast<void (*)(int)>(t); } //ok
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (&)(char)>(t); } // expected-error{{cannot resolve}}
54*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<void (*)(char)>(t); } // expected-error{{cannot resolve}}
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc   { bool b = reinterpret_cast<int (*)(char)>(g); } //ok
57*f4a2713aSLionel Sambuc   { bool b = static_cast<int (*)(char)>(t); } // expected-error{{cannot be static_cast}}
58*f4a2713aSLionel Sambuc   { bool b = static_cast<int (&)(char)>(t); } // expected-error{{does not match required}}
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc   { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
61*f4a2713aSLionel Sambuc }
62