blob: 1e396e976575d0a16fb464abde43e5ffd8791bf7 [file] [log] [blame]
Fariborz Jahanian7a1f4cc2009-10-23 18:08:22 +00001// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s &&
2// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
3// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s &&
4// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
5// RUN: true
6// 13.3.3.2 Ranking implicit conversion sequences
7
8extern "C" int printf(...);
9
10struct A {
11int Ai;
12};
13
14struct B : public A {
15 void bf() { printf("B::bf called\n"); }
16};
17
18struct C : public B { };
19
20// conversion of B::* to C::* is better than conversion of A::* to C::*
21typedef void (A::*pmfa)();
22typedef void (B::*pmfb)();
23typedef void (C::*pmfc)();
24
25struct X {
26 operator pmfa();
27 operator pmfb() {
28 return &B::bf;
29 }
30};
31
32
33void g(pmfc pm) {
34 C c;
35 (c.*pm)();
36}
37
38void test2(X x)
39{
40 g(x);
41}
42
43int main()
44{
45 X x;
46 test2(x);
47}
48
49// CHECK-LP64: call __ZN1XcvM1BFvvEEv
50// CHECK-LP64: call __Z1gM1CFvvE
51
52// CHECK-LP32: call L__ZN1XcvM1BFvvEEv
53// CHECK-LP32: call __Z1gM1CFvvE