[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / convert-to-fptr.cpp
blob3d18f7684f25c3cdb36cda2706e6735cf9bdae46
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
6 extern "C" int printf(...);
8 int f1(int arg) { return arg; };
10 int f2(float arg) { return int(arg); };
12 typedef int (*fp1)(int);
14 typedef int (*fp2)(float);
16 struct A {
17 operator fp1() { return f1; }
18 operator fp2() { return f2; }
19 } a;
22 // Test for function reference.
23 typedef int (&fr1)(int);
24 typedef int (&fr2)(float);
26 struct B {
27 operator fr1() { return f1; }
28 operator fr2() { return f2; }
29 } b;
31 int main()
33 int i = a(10); // Calls f1 via pointer returned from conversion function
34 printf("i = %d\n", i);
36 int j = b(20); // Calls f1 via pointer returned from conversion function
37 printf("j = %d\n", j);
38 return 0;
41 // CHECK: call noundef ptr @_ZN1AcvPFiiEEv
42 // CHECK: call noundef nonnull ptr @_ZN1BcvRFiiEEv