| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s |
| 2 |
// RUN: FileCheck -check-prefix COMMON %s < %t |
| 3 |
// RUN: FileCheck -check-prefix X86_64 %s < %t |
| 4 |
// RUN: %clang_cc1 -triple i386-apple-darwin10 -funknown-anytype -emit-llvm -o %t %s |
| 5 |
// RUN: FileCheck -check-prefix COMMON %s < %t |
| 6 |
// RUN: FileCheck -check-prefix I386 %s < %t |
| 7 |
|
| 8 |
// x86-64 is the special case here because of its variadic convention. |
| 9 |
// We want to ensure that it always uses a variadic convention even if |
| 10 |
// other platforms do not. |
| 11 |
|
| 12 |
int test0() { |
| 13 |
extern __unknown_anytype test0_any; |
| 14 |
// COMMON: load i32, ptr @test0_any |
| 15 |
return (int) test0_any; |
| 16 |
} |
| 17 |
|
| 18 |
int test1() { |
| 19 |
extern __unknown_anytype test1_any(); |
| 20 |
// COMMON: call noundef i32 @_Z9test1_anyv() |
| 21 |
return (int) test1_any(); |
| 22 |
} |
| 23 |
|
| 24 |
extern "C" __unknown_anytype test2_any(...); |
| 25 |
float test2() { |
| 26 |
// X86_64: call float (double, ...) @test2_any(double {{[^,]+}}) |
| 27 |
// I386: call float (double, ...) @test2_any(double {{[^,]+}}) |
| 28 |
return (float) test2_any(0.5f); |
| 29 |
} |
| 30 |
|
| 31 |
extern "C" __unknown_anytype test2a_any(...); |
| 32 |
float test2a() { |
| 33 |
// X86_64: call float (float, ...) @test2a_any(float {{[^,]+}}) |
| 34 |
// I386: call float (float, ...) @test2a_any(float {{[^,]+}}) |
| 35 |
return (float) test2a_any((float) 0.5f); |
| 36 |
} |
| 37 |
|
| 38 |
float test3() { |
| 39 |
extern __unknown_anytype test3_any; |
| 40 |
// COMMON: [[FN:%.*]] = load ptr, ptr @test3_any, |
| 41 |
// COMMON: call noundef float [[FN]](i32 noundef 5) |
| 42 |
return ((float(*)(int)) test3_any)(5); |
| 43 |
} |
| 44 |
|
| 45 |
namespace test4 { |
| 46 |
extern __unknown_anytype test4_any1; |
| 47 |
extern __unknown_anytype test4_any2; |
| 48 |
|
| 49 |
int test() { |
| 50 |
// COMMON: load i32, ptr @_ZN5test410test4_any1E |
| 51 |
// COMMON: load i8, ptr @_ZN5test410test4_any2E |
| 52 |
return (int) test4_any1 + (char) test4_any2; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
extern "C" __unknown_anytype test5_any(); |
| 57 |
void test5() { |
| 58 |
// COMMON: call void @test5_any() |
| 59 |
return (void) test5_any(); |
| 60 |
} |
| 61 |
|
| 62 |
extern "C" __unknown_anytype test6_any(float *); |
| 63 |
long test6() { |
| 64 |
// COMMON: call i64 @test6_any(ptr noundef null) |
| 65 |
return (long long) test6_any(0); |
| 66 |
} |
| 67 |
|
| 68 |
struct Test7 { |
| 69 |
~Test7(); |
| 70 |
}; |
| 71 |
extern "C" __unknown_anytype test7_any(int); |
| 72 |
Test7 test7() { |
| 73 |
// COMMON: call void @test7_any(ptr dead_on_unwind writable sret({{%.*}}) align 1 {{%.*}}, i32 noundef 5) |
| 74 |
return (Test7) test7_any(5); |
| 75 |
} |
| 76 |
|
| 77 |
struct Test8 { |
| 78 |
__unknown_anytype foo(); |
| 79 |
__unknown_anytype foo(int); |
| 80 |
|
| 81 |
void test(); |
| 82 |
}; |
| 83 |
void Test8::test() { |
| 84 |
float f; |
| 85 |
// COMMON: call noundef i32 @_ZN5Test83fooEv( |
| 86 |
f = (int) foo(); |
| 87 |
// COMMON: call noundef i32 @_ZN5Test83fooEi( |
| 88 |
f = (int) foo(5); |
| 89 |
// COMMON: call noundef i32 @_ZN5Test83fooEv( |
| 90 |
f = (float) this->foo(); |
| 91 |
// COMMON: call noundef i32 @_ZN5Test83fooEi( |
| 92 |
f = (float) this->foo(5); |
| 93 |
} |
| 94 |
void test8(Test8 *p) { |
| 95 |
double d; |
| 96 |
// COMMON: call noundef i32 @_ZN5Test83fooEv( |
| 97 |
d = (double) p->foo(); |
| 98 |
// COMMON: call noundef i32 @_ZN5Test83fooEi( |
| 99 |
d = (double) p->foo(5); |
| 100 |
// COMMON: call noundef i32 @_ZN5Test83fooEv( |
| 101 |
d = (bool) (*p).foo(); |
| 102 |
// COMMON: call noundef i32 @_ZN5Test83fooEi( |
| 103 |
d = (bool) (*p).foo(5); |
| 104 |
} |
| 105 |
|
| 106 |
extern "C" __unknown_anytype test9_foo; |
| 107 |
void *test9() { |
| 108 |
// COMMON: ret ptr @test9_foo |
| 109 |
return (int*) &test9_foo; |
| 110 |
} |
| 111 |
|
| 112 |
// Don't explode on this. |
| 113 |
extern "C" __unknown_anytype test10_any(...); |
| 114 |
void test10() { |
| 115 |
(void) test10_any(), (void) test10_any(); |
| 116 |
} |
| 117 |
|
| 118 |
extern "C" __unknown_anytype malloc(...); |
| 119 |
void test11() { |
| 120 |
void *s = (void*)malloc(12); |
| 121 |
// COMMON: call ptr (i32, ...) @malloc(i32 noundef 12) |
| 122 |
void *d = (void*)malloc(435); |
| 123 |
// COMMON: call ptr (i32, ...) @malloc(i32 noundef 435) |
| 124 |
} |