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