xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/ptrtomember-overload-resolution.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // 13.3.3.2 Ranking implicit conversion sequences
5*f4a2713aSLionel Sambuc // conversion of A::* to B::* is better than conversion of A::* to C::*,
6*f4a2713aSLionel Sambuc struct A {
7*f4a2713aSLionel Sambuc int Ai;
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc struct B : public A {};
11*f4a2713aSLionel Sambuc struct C : public B {};
12*f4a2713aSLionel Sambuc 
f(int C::*)13*f4a2713aSLionel Sambuc const char * f(int C::*){ return ""; }
f(int B::*)14*f4a2713aSLionel Sambuc int f(int B::*) { return 1; }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc struct D : public C {};
17*f4a2713aSLionel Sambuc 
g(int B::*)18*f4a2713aSLionel Sambuc const char * g(int B::*){ return ""; }
g(int D::*)19*f4a2713aSLionel Sambuc int g(int D::*) { return 1; }
20*f4a2713aSLionel Sambuc 
test()21*f4a2713aSLionel Sambuc void test()
22*f4a2713aSLionel Sambuc {
23*f4a2713aSLionel Sambuc   int i = f(&A::Ai);
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc   const char * str = g(&A::Ai);
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // conversion of B::* to C::* is better than conversion of A::* to C::*
29*f4a2713aSLionel Sambuc typedef void (A::*pmfa)();
30*f4a2713aSLionel Sambuc typedef void (B::*pmfb)();
31*f4a2713aSLionel Sambuc typedef void (C::*pmfc)();
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc struct X {
34*f4a2713aSLionel Sambuc 	operator pmfa();
35*f4a2713aSLionel Sambuc 	operator pmfb();
36*f4a2713aSLionel Sambuc };
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc void g(pmfc);
40*f4a2713aSLionel Sambuc 
test2(X x)41*f4a2713aSLionel Sambuc void test2(X x)
42*f4a2713aSLionel Sambuc {
43*f4a2713aSLionel Sambuc     g(x);
44*f4a2713aSLionel Sambuc }
45*f4a2713aSLionel Sambuc 
46