| 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 |
|
| 8 |
int f1(int arg) { return arg; }; |
| 9 |
|
| 10 |
int f2(float arg) { return int(arg); }; |
| 11 |
|
| 12 |
typedef int (*fp1)(int); |
| 13 |
|
| 14 |
typedef int (*fp2)(float); |
| 15 |
|
| 16 |
struct A { |
| 17 |
operator fp1() { return f1; } |
| 18 |
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 { |
| 27 |
operator fr1() { return f1; } |
| 28 |
operator fr2() { return f2; } |
| 29 |
} b; |
| 30 |
|
| 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 noundef ptr @_ZN1AcvPFiiEEv |
| 42 |
// CHECK: call noundef nonnull ptr @_ZN1BcvRFiiEEv |