blob: 902cc8de5c97a862dbca65dd60b5211fb05c729a [file] [log] [blame]
John McCalla5fc4722011-04-09 22:50:59 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o - %s | FileCheck %s
2
3int test0() {
4 extern __unknown_anytype test0_any;
5 // CHECK: load i32* @test0_any
6 return (int) test0_any;
7}
8
9int test1() {
John McCall755d8492011-04-12 00:42:48 +000010 extern __unknown_anytype test1_any();
11 // CHECK: call i32 @_Z9test1_anyv()
John McCalla5fc4722011-04-09 22:50:59 +000012 return (int) test1_any();
13}
14
John McCall755d8492011-04-12 00:42:48 +000015extern "C" __unknown_anytype test2_any(...);
John McCalla5fc4722011-04-09 22:50:59 +000016float test2() {
John McCall755d8492011-04-12 00:42:48 +000017 // CHECK: call float (...)* @test2_any(double {{[^,]+}})
John McCalla5fc4722011-04-09 22:50:59 +000018 return (float) test2_any(0.5f);
19}
20
John McCall755d8492011-04-12 00:42:48 +000021extern "C" __unknown_anytype test2a_any(...);
22float test2a() {
23 // CHECK: call float (...)* @test2a_any(float {{[^,]+}})
24 return (float) test2a_any((float) 0.5f);
25}
26
John McCalla5fc4722011-04-09 22:50:59 +000027float test3() {
28 extern __unknown_anytype test3_any;
John McCall755d8492011-04-12 00:42:48 +000029 // CHECK: [[FN:%.*]] = load float (i32)** @test3_any,
30 // CHECK: call float [[FN]](i32 5)
31 return ((float(*)(int)) test3_any)(5);
John McCalla5fc4722011-04-09 22:50:59 +000032}
33
34namespace test4 {
35 extern __unknown_anytype test4_any1;
36 extern __unknown_anytype test4_any2;
37
38 int test() {
39 // CHECK: load i32* @_ZN5test410test4_any1E
John McCall755d8492011-04-12 00:42:48 +000040 // CHECK: load i8* @_ZN5test410test4_any2E
41 return (int) test4_any1 + (char) test4_any2;
John McCalla5fc4722011-04-09 22:50:59 +000042 }
43}
44
John McCall755d8492011-04-12 00:42:48 +000045extern "C" __unknown_anytype test5_any();
John McCalla5fc4722011-04-09 22:50:59 +000046void test5() {
John McCalla5fc4722011-04-09 22:50:59 +000047 // CHECK: call void @test5_any()
48 return (void) test5_any();
49}
50
John McCall755d8492011-04-12 00:42:48 +000051extern "C" __unknown_anytype test6_any(float *);
John McCalla5fc4722011-04-09 22:50:59 +000052long test6() {
John McCall755d8492011-04-12 00:42:48 +000053 // CHECK: call i64 @test6_any(float* null)
John McCalla5fc4722011-04-09 22:50:59 +000054 return (long) test6_any(0);
55}
56
57struct Test7 {
58 ~Test7();
59};
John McCall755d8492011-04-12 00:42:48 +000060extern "C" __unknown_anytype test7_any(int);
John McCalla5fc4722011-04-09 22:50:59 +000061Test7 test7() {
John McCalla5fc4722011-04-09 22:50:59 +000062 // CHECK: call void @test7_any({{%.*}}* sret {{%.*}}, i32 5)
63 return (Test7) test7_any(5);
64}
John McCall379b5152011-04-11 07:02:50 +000065
66struct Test8 {
67 __unknown_anytype foo();
68 __unknown_anytype foo(int);
69
70 void test();
71};
72void Test8::test() {
John McCall755d8492011-04-12 00:42:48 +000073 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);
John McCall379b5152011-04-11 07:02:50 +000082}
83void test8(Test8 *p) {
John McCall755d8492011-04-12 00:42:48 +000084 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
95extern "C" __unknown_anytype test9_foo;
96void *test9() {
97 // CHECK: ret i8* bitcast (i32* @test9_foo to i8*)
98 return (int*) &test9_foo;
John McCall379b5152011-04-11 07:02:50 +000099}