blob: 85ed0aaa4f9e2181c8cc5b040218bdae2661450c [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
Andy Gibbs8e8fb3b2012-10-19 12:44:48 +00002// expected-no-diagnostics
Fariborz Jahanian8577c982009-10-20 20:04:46 +00003
4// 13.3.3.2 Ranking implicit conversion sequences
5// conversion of A::* to B::* is better than conversion of A::* to C::*,
6struct A {
7int Ai;
8};
9
10struct B : public A {};
11struct C : public B {};
12
13const char * f(int C::*){ return ""; }
14int f(int B::*) { return 1; }
15
16struct D : public C {};
17
18const char * g(int B::*){ return ""; }
19int g(int D::*) { return 1; }
20
21void test()
22{
23 int i = f(&A::Ai);
24
25 const char * str = g(&A::Ai);
26}
27
28// conversion of B::* to C::* is better than conversion of A::* to C::*
29typedef void (A::*pmfa)();
30typedef void (B::*pmfb)();
31typedef void (C::*pmfc)();
32
33struct X {
34 operator pmfa();
35 operator pmfb();
36};
37
38
39void g(pmfc);
40
41void test2(X x)
42{
43 g(x);
44}
45