brintos

brintos / llvm-project-archived public Read only

0
0
Text · 936 B · 3d18f76 Raw
43 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | \2// RUN: FileCheck %s3// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -emit-llvm %s -o - | \4// RUN: FileCheck %s5 6extern "C" int printf(...);7 8int f1(int arg)  { return arg; }; 9 10int f2(float arg) { return int(arg); }; 11 12typedef int (*fp1)(int); 13 14typedef int (*fp2)(float); 15 16struct A {17  operator fp1() { return f1; }18  operator fp2() { return f2; } 19} a;20 21 22// Test for function reference.23typedef int (&fr1)(int); 24typedef int (&fr2)(float); 25 26struct B {27  operator fr1() { return f1; }28  operator fr2() { return f2; } 29} b;30 31int main()32{33 int i = a(10); // Calls f1 via pointer returned from conversion function34 printf("i = %d\n", i);35 36 int j = b(20); // Calls f1 via pointer returned from conversion function37 printf("j = %d\n", j);38 return 0;39}40 41// CHECK: call noundef ptr @_ZN1AcvPFiiEEv42// CHECK: call noundef nonnull ptr @_ZN1BcvRFiiEEv43