1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc void g();
3f4a2713aSLionel Sambuc
4*0a6a1f1dSLionel Sambuc void f(); // expected-note 11{{candidate function}}
5*0a6a1f1dSLionel Sambuc void f(int); // expected-note 11{{candidate function}}
6f4a2713aSLionel Sambuc
7f4a2713aSLionel Sambuc template <class T>
8f4a2713aSLionel Sambuc void t(T); // expected-note 3{{candidate function}} \
9f4a2713aSLionel Sambuc // expected-note 3{{candidate template ignored: could not match 'void' against 'int'}}
10f4a2713aSLionel Sambuc template <class T>
11f4a2713aSLionel Sambuc void t(T *); // expected-note 3{{candidate function}} \
12f4a2713aSLionel Sambuc // expected-note 3{{candidate template ignored: could not match 'void' against 'int'}}
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc template<class T> void u(T);
15f4a2713aSLionel Sambuc
main()16f4a2713aSLionel Sambuc int main()
17f4a2713aSLionel Sambuc {
18f4a2713aSLionel Sambuc { bool b = (void (&)(char))f; } // expected-error{{does not match required type}}
19f4a2713aSLionel Sambuc { bool b = (void (*)(char))f; } // expected-error{{does not match required type}}
20f4a2713aSLionel Sambuc
21f4a2713aSLionel Sambuc { bool b = (void (&)(int))f; } //ok
22f4a2713aSLionel Sambuc { bool b = (void (*)(int))f; } //ok
23f4a2713aSLionel Sambuc
24f4a2713aSLionel Sambuc { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
25f4a2713aSLionel Sambuc { bool b = static_cast<void (*)(char)>(f); } // expected-error{{address of overloaded function}}
26f4a2713aSLionel Sambuc
27f4a2713aSLionel Sambuc { bool b = static_cast<void (&)(int)>(f); } //ok
28f4a2713aSLionel Sambuc { bool b = static_cast<void (*)(int)>(f); } //ok
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc
31f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (&)(char)>(f); } // expected-error{{cannot resolve}}
32f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (*)(char)>(f); } // expected-error{{cannot resolve}}
33f4a2713aSLionel Sambuc
34f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (*)(char)>(g); } //ok
35f4a2713aSLionel Sambuc { bool b = static_cast<void (*)(char)>(g); } // expected-error{{not allowed}}
36f4a2713aSLionel Sambuc
37f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (&)(int)>(f); } // expected-error{{cannot resolve}}
38f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (*)(int)>(f); } // expected-error{{cannot resolve}}
39f4a2713aSLionel Sambuc
40f4a2713aSLionel Sambuc { bool b = (int (&)(char))t; } // expected-error{{does not match}}
41f4a2713aSLionel Sambuc { bool b = (int (*)(char))t; } // expected-error{{does not match}}
42f4a2713aSLionel Sambuc
43f4a2713aSLionel Sambuc { bool b = (void (&)(int))t; } //ok
44f4a2713aSLionel Sambuc { bool b = (void (*)(int))t; } //ok
45f4a2713aSLionel Sambuc
46f4a2713aSLionel Sambuc { bool b = static_cast<void (&)(char)>(t); } //ok
47f4a2713aSLionel Sambuc { bool b = static_cast<void (*)(char)>(t); } //ok
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc { bool b = static_cast<void (&)(int)>(t); } //ok
50f4a2713aSLionel Sambuc { bool b = static_cast<void (*)(int)>(t); } //ok
51f4a2713aSLionel Sambuc
52f4a2713aSLionel Sambuc
53f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (&)(char)>(t); } // expected-error{{cannot resolve}}
54f4a2713aSLionel Sambuc { bool b = reinterpret_cast<void (*)(char)>(t); } // expected-error{{cannot resolve}}
55f4a2713aSLionel Sambuc
56f4a2713aSLionel Sambuc { bool b = reinterpret_cast<int (*)(char)>(g); } //ok
57f4a2713aSLionel Sambuc { bool b = static_cast<int (*)(char)>(t); } // expected-error{{cannot be static_cast}}
58f4a2713aSLionel Sambuc { bool b = static_cast<int (&)(char)>(t); } // expected-error{{does not match required}}
59f4a2713aSLionel Sambuc
60f4a2713aSLionel Sambuc { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc {
63*0a6a1f1dSLionel Sambuc // The error should be reported when casting overloaded function to the
64*0a6a1f1dSLionel Sambuc // compatible function type (not to be confused with function pointer or
65*0a6a1f1dSLionel Sambuc // function reference type.)
66*0a6a1f1dSLionel Sambuc typedef void (FnType)(int);
67*0a6a1f1dSLionel Sambuc FnType a = static_cast<FnType>(f); // expected-error{{address of overloaded function}}
68*0a6a1f1dSLionel Sambuc FnType b = (FnType)(f); // expected-error{{address of overloaded function}}
69*0a6a1f1dSLionel Sambuc }
70f4a2713aSLionel Sambuc }
71