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