1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o - %s | FileCheck %s 2 3 int test0() { 4 extern __unknown_anytype test0_any; 5 // CHECK: load i32* @test0_any 6 return (int) test0_any; 7 } 8 9 int test1() { 10 extern __unknown_anytype test1_any(); 11 // CHECK: call i32 @_Z9test1_anyv() 12 return (int) test1_any(); 13 } 14 15 extern "C" __unknown_anytype test2_any(...); 16 float test2() { 17 // CHECK: call float (...)* @test2_any(double {{[^,]+}}) 18 return (float) test2_any(0.5f); 19 } 20 21 extern "C" __unknown_anytype test2a_any(...); 22 float test2a() { 23 // CHECK: call float (...)* @test2a_any(float {{[^,]+}}) 24 return (float) test2a_any((float) 0.5f); 25 } 26 27 float test3() { 28 extern __unknown_anytype test3_any; 29 // CHECK: [[FN:%.*]] = load float (i32)** @test3_any, 30 // CHECK: call float [[FN]](i32 5) 31 return ((float(*)(int)) test3_any)(5); 32 } 33 34 namespace test4 { 35 extern __unknown_anytype test4_any1; 36 extern __unknown_anytype test4_any2; 37 38 int test() { 39 // CHECK: load i32* @_ZN5test410test4_any1E 40 // CHECK: load i8* @_ZN5test410test4_any2E 41 return (int) test4_any1 + (char) test4_any2; 42 } 43 } 44 45 extern "C" __unknown_anytype test5_any(); 46 void test5() { 47 // CHECK: call void @test5_any() 48 return (void) test5_any(); 49 } 50 51 extern "C" __unknown_anytype test6_any(float *); 52 long test6() { 53 // CHECK: call i64 @test6_any(float* null) 54 return (long) test6_any(0); 55 } 56 57 struct Test7 { 58 ~Test7(); 59 }; 60 extern "C" __unknown_anytype test7_any(int); 61 Test7 test7() { 62 // CHECK: call void @test7_any({{%.*}}* sret {{%.*}}, i32 5) 63 return (Test7) test7_any(5); 64 } 65 66 struct Test8 { 67 __unknown_anytype foo(); 68 __unknown_anytype foo(int); 69 70 void test(); 71 }; 72 void Test8::test() { 73 float f; 74 // CHECK: call i32 @_ZN5Test83fooEv( 75 f = (int) foo(); 76 // CHECK: call i32 @_ZN5Test83fooEi( 77 f = (int) foo(5); 78 // CHECK: call i32 @_ZN5Test83fooEv( 79 f = (float) this->foo(); 80 // CHECK: call i32 @_ZN5Test83fooEi( 81 f = (float) this->foo(5); 82 } 83 void test8(Test8 *p) { 84 double d; 85 // CHECK: call i32 @_ZN5Test83fooEv( 86 d = (double) p->foo(); 87 // CHECK: call i32 @_ZN5Test83fooEi( 88 d = (double) p->foo(5); 89 // CHECK: call i32 @_ZN5Test83fooEv( 90 d = (bool) (*p).foo(); 91 // CHECK: call i32 @_ZN5Test83fooEi( 92 d = (bool) (*p).foo(5); 93 } 94 95 extern "C" __unknown_anytype test9_foo; 96 void *test9() { 97 // CHECK: ret i8* bitcast (i32* @test9_foo to i8*) 98 return (int*) &test9_foo; 99 } 100