• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2 
3 // 13.3.3.2 Ranking implicit conversion sequences
4 // conversion of A::* to B::* is better than conversion of A::* to C::*,
5 struct A {
6 int Ai;
7 };
8 
9 struct B : public A {};
10 struct C : public B {};
11 
f(int C::*)12 const char * f(int C::*){ return ""; }
f(int B::*)13 int f(int B::*) { return 1; }
14 
15 struct D : public C {};
16 
g(int B::*)17 const char * g(int B::*){ return ""; }
g(int D::*)18 int g(int D::*) { return 1; }
19 
test()20 void 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::*
28 typedef void (A::*pmfa)();
29 typedef void (B::*pmfb)();
30 typedef void (C::*pmfc)();
31 
32 struct X {
33 	operator pmfa();
34 	operator pmfb();
35 };
36 
37 
38 void g(pmfc);
39 
test2(X x)40 void test2(X x)
41 {
42     g(x);
43 }
44 
45