1*f4a2713aSLionel Sambuc // REQUIRES: x86-registered-target,x86-64-registered-target 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s 3*f4a2713aSLionel Sambuc // RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s 4*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s 5*f4a2713aSLionel Sambuc // RUN: FileCheck -check-prefix CHECK-LP32 --input-file=%t-32.s %s 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc extern "C" int printf(...); 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc int f1(int arg) { return arg; }; 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc int f2(float arg) { return int(arg); }; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc typedef int (*fp1)(int); 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc typedef int (*fp2)(float); 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc struct A { 18*f4a2713aSLionel Sambuc operator fp1() { return f1; } 19*f4a2713aSLionel Sambuc operator fp2() { return f2; } 20*f4a2713aSLionel Sambuc } a; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc // Test for function reference. 24*f4a2713aSLionel Sambuc typedef int (&fr1)(int); 25*f4a2713aSLionel Sambuc typedef int (&fr2)(float); 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc struct B { 28*f4a2713aSLionel Sambuc operator fr1() { return f1; } 29*f4a2713aSLionel Sambuc operator fr2() { return f2; } 30*f4a2713aSLionel Sambuc } b; 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc int main() 33*f4a2713aSLionel Sambuc { 34*f4a2713aSLionel Sambuc int i = a(10); // Calls f1 via pointer returned from conversion function 35*f4a2713aSLionel Sambuc printf("i = %d\n", i); 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc int j = b(20); // Calls f1 via pointer returned from conversion function 38*f4a2713aSLionel Sambuc printf("j = %d\n", j); 39*f4a2713aSLionel Sambuc return 0; 40*f4a2713aSLionel Sambuc } 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc // CHECK-LP64: callq __ZN1AcvPFiiEEv 43*f4a2713aSLionel Sambuc // CHECK-LP64: callq __ZN1BcvRFiiEEv 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc // CHECK-LP32: calll L__ZN1AcvPFiiEEv 46*f4a2713aSLionel Sambuc // CHECK-LP32: calll L__ZN1BcvRFiiEEv 47*f4a2713aSLionel Sambuc 48