Fariborz Jahanian | 7a1f4cc | 2009-10-23 18:08:22 +0000 | [diff] [blame^] | 1 | // 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 | |
| 8 | extern "C" int printf(...); |
| 9 | |
| 10 | struct A { |
| 11 | int Ai; |
| 12 | }; |
| 13 | |
| 14 | struct B : public A { |
| 15 | void bf() { printf("B::bf called\n"); } |
| 16 | }; |
| 17 | |
| 18 | struct C : public B { }; |
| 19 | |
| 20 | // conversion of B::* to C::* is better than conversion of A::* to C::* |
| 21 | typedef void (A::*pmfa)(); |
| 22 | typedef void (B::*pmfb)(); |
| 23 | typedef void (C::*pmfc)(); |
| 24 | |
| 25 | struct X { |
| 26 | operator pmfa(); |
| 27 | operator pmfb() { |
| 28 | return &B::bf; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | void g(pmfc pm) { |
| 34 | C c; |
| 35 | (c.*pm)(); |
| 36 | } |
| 37 | |
| 38 | void test2(X x) |
| 39 | { |
| 40 | g(x); |
| 41 | } |
| 42 | |
| 43 | int 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 |