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