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 7 extern "C" int printf(...); 8 9 int f1(int arg) { return arg; }; 10 11 int f2(float arg) { return int(arg); }; 12 13 typedef int (*fp1)(int); 14 15 typedef int (*fp2)(float); 16 17 struct A { 18 operator fp1() { return f1; } 19 operator fp2() { return f2; } 20 } a; 21 22 23 // Test for function reference. 24 typedef int (&fr1)(int); 25 typedef int (&fr2)(float); 26 27 struct B { 28 operator fr1() { return f1; } 29 operator fr2() { return f2; } 30 } b; 31 32 int main() 33 { 34 int i = a(10); // Calls f1 via pointer returned from conversion function 35 printf("i = %d\n", i); 36 37 int j = b(20); // Calls f1 via pointer returned from conversion function 38 printf("j = %d\n", j); 39 return 0; 40 } 41 42 // CHECK-LP64: callq __ZN1AcvPFiiEEv 43 // CHECK-LP64: callq __ZN1BcvRFiiEEv 44 45 // CHECK-LP32: calll L__ZN1AcvPFiiEEv 46 // CHECK-LP32: calll L__ZN1BcvRFiiEEv 47 48