1// REQUIRES: x86-registered-target,x86-64-registered-target 2// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s 3// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s 4// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s 5// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s 6// 13.3.3.2 Ranking implicit conversion sequences 7 8extern "C" int printf(...); 9 10struct A { 11int Ai; 12bool foo(int* arg) const; 13}; 14 15bool A::foo(int* arg) const { 16 printf("A::foo(%d)\n", *arg); 17 return true; 18} 19 20struct B : public A { 21 void bf() { printf("B::bf called\n"); } 22}; 23 24struct C : public B { }; 25 26// conversion of B::* to C::* is better than conversion of A::* to C::* 27typedef void (A::*pmfa)(); 28typedef void (B::*pmfb)(); 29typedef void (C::*pmfc)(); 30 31struct X { 32 operator pmfa(); 33 operator pmfb() { 34 return &B::bf; 35 } 36}; 37 38 39void g(pmfc pm) { 40 C c; 41 (c.*pm)(); 42} 43 44void test2(X x) 45{ 46 g(x); 47} 48 49struct B1 { 50 bool (A::*pmf)(int*) const; 51 52 B1(int i) : pmf(&A::foo), im(i) { 53 ((A*)this->*pmf)(&im); 54 } 55 56 int im; 57}; 58 59int main() 60{ 61 X x; 62 test2(x); 63 B1 b = B1(1); 64 B1 c = B1(2); 65} 66 67// CHECK-LP64: callq __ZN1XcvM1BFvvEEv 68// CHECK-LP64: callq __Z1gM1CFvvE 69 70// CHECK-LP32: calll L__ZN1XcvM1BFvvEEv 71// CHECK-LP32: calll __Z1gM1CFvvE 72