1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \ 2*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s 3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \ 4*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc extern "C" int printf(...); 7f4a2713aSLionel Sambuc f1(int arg)8f4a2713aSLionel Sambucint f1(int arg) { return arg; }; 9f4a2713aSLionel Sambuc f2(float arg)10f4a2713aSLionel Sambucint f2(float arg) { return int(arg); }; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc typedef int (*fp1)(int); 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc typedef int (*fp2)(float); 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambuc struct A { operator fp1A17f4a2713aSLionel Sambuc operator fp1() { return f1; } operator fp2A18f4a2713aSLionel Sambuc operator fp2() { return f2; } 19f4a2713aSLionel Sambuc } a; 20f4a2713aSLionel Sambuc 21f4a2713aSLionel Sambuc 22f4a2713aSLionel Sambuc // Test for function reference. 23f4a2713aSLionel Sambuc typedef int (&fr1)(int); 24f4a2713aSLionel Sambuc typedef int (&fr2)(float); 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambuc struct B { operator fr1B27f4a2713aSLionel Sambuc operator fr1() { return f1; } operator fr2B28f4a2713aSLionel Sambuc operator fr2() { return f2; } 29f4a2713aSLionel Sambuc } b; 30f4a2713aSLionel Sambuc main()31f4a2713aSLionel Sambucint main() 32f4a2713aSLionel Sambuc { 33f4a2713aSLionel Sambuc int i = a(10); // Calls f1 via pointer returned from conversion function 34f4a2713aSLionel Sambuc printf("i = %d\n", i); 35f4a2713aSLionel Sambuc 36f4a2713aSLionel Sambuc int j = b(20); // Calls f1 via pointer returned from conversion function 37f4a2713aSLionel Sambuc printf("j = %d\n", j); 38f4a2713aSLionel Sambuc return 0; 39f4a2713aSLionel Sambuc } 40f4a2713aSLionel Sambuc 41*0a6a1f1dSLionel Sambuc // CHECK: call i32 (i32)* (%struct.A*)* @_ZN1AcvPFiiEEv 42*0a6a1f1dSLionel Sambuc // CHECK: call i32 (i32)* (%struct.B*)* @_ZN1BcvRFiiEEv 43