John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 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() { |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 10 | extern __unknown_anytype test1_any(); |
| 11 | // CHECK: call i32 @_Z9test1_anyv() |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 12 | return (int) test1_any(); |
| 13 | } |
| 14 | |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 15 | extern "C" __unknown_anytype test2_any(...); |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 16 | float test2() { |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 17 | // CHECK: call float (...)* @test2_any(double {{[^,]+}}) |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 18 | return (float) test2_any(0.5f); |
| 19 | } |
| 20 | |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 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 | |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 27 | float test3() { |
| 28 | extern __unknown_anytype test3_any; |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 29 | // CHECK: [[FN:%.*]] = load float (i32)** @test3_any, |
| 30 | // CHECK: call float [[FN]](i32 5) |
| 31 | return ((float(*)(int)) test3_any)(5); |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 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 |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 40 | // CHECK: load i8* @_ZN5test410test4_any2E |
| 41 | return (int) test4_any1 + (char) test4_any2; |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 45 | extern "C" __unknown_anytype test5_any(); |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 46 | void test5() { |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 47 | // CHECK: call void @test5_any() |
| 48 | return (void) test5_any(); |
| 49 | } |
| 50 | |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 51 | extern "C" __unknown_anytype test6_any(float *); |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 52 | long test6() { |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 53 | // CHECK: call i64 @test6_any(float* null) |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 54 | return (long) test6_any(0); |
| 55 | } |
| 56 | |
| 57 | struct Test7 { |
| 58 | ~Test7(); |
| 59 | }; |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 60 | extern "C" __unknown_anytype test7_any(int); |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 61 | Test7 test7() { |
John McCall | a5fc472 | 2011-04-09 22:50:59 +0000 | [diff] [blame] | 62 | // CHECK: call void @test7_any({{%.*}}* sret {{%.*}}, i32 5) |
| 63 | return (Test7) test7_any(5); |
| 64 | } |
John McCall | 379b515 | 2011-04-11 07:02:50 +0000 | [diff] [blame] | 65 | |
| 66 | struct Test8 { |
| 67 | __unknown_anytype foo(); |
| 68 | __unknown_anytype foo(int); |
| 69 | |
| 70 | void test(); |
| 71 | }; |
| 72 | void Test8::test() { |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 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); |
John McCall | 379b515 | 2011-04-11 07:02:50 +0000 | [diff] [blame] | 82 | } |
| 83 | void test8(Test8 *p) { |
John McCall | 755d849 | 2011-04-12 00:42:48 +0000 | [diff] [blame] | 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; |
John McCall | 379b515 | 2011-04-11 07:02:50 +0000 | [diff] [blame] | 99 | } |