2010-07-14 07:27:15 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
|
|
|
|
|
|
|
|
struct X { int i; float f; };
|
|
|
|
struct Y { X x; };
|
|
|
|
|
|
|
|
// CHECK: define void @_Z21reinterpret_cast_testRiRfR1X
|
|
|
|
void reinterpret_cast_test(int &ir, float &fr, X &xr) {
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = reinterpret_cast<int&>(fr);
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to i32\*}}
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = reinterpret_cast<int&>(xr);
|
|
|
|
// CHECK: load i32
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = reinterpret_cast<float&>(ir);
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = reinterpret_cast<float&>(xr);
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = reinterpret_cast<X&>(ir);
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = reinterpret_cast<X&>(fr);
|
2010-07-15 05:35:45 +08:00
|
|
|
_Complex float cf;
|
|
|
|
_Complex float &cfr = cf;
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = reinterpret_cast<_Complex float&>(ir);
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = reinterpret_cast<_Complex float&>(fr);
|
|
|
|
// CHECK: bitcast
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = reinterpret_cast<_Complex float&>(xr);
|
2010-07-14 07:27:15 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: define void @_Z6c_castRiRfR1X
|
|
|
|
void c_cast(int &ir, float &fr, X &xr) {
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = (int&)fr;
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to i32\*}}
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = (int&)xr;
|
|
|
|
// CHECK: load i32
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = (float&)ir;
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = (float&)xr;
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = (X&)ir;
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = (X&)fr;
|
2010-07-15 05:35:45 +08:00
|
|
|
_Complex float cf;
|
|
|
|
_Complex float &cfr = cf;
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = (_Complex float&)ir;
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = (_Complex float&)fr;
|
|
|
|
// CHECK: bitcast
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = (_Complex float&)xr;
|
2010-07-14 07:27:15 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: define void @_Z15functional_castRiRfR1X
|
|
|
|
void functional_cast(int &ir, float &fr, X &xr) {
|
|
|
|
typedef int &intref;
|
|
|
|
typedef float &floatref;
|
|
|
|
typedef X &Xref;
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = intref(fr);
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to i32\*}}
|
|
|
|
// CHECK: load i32*
|
|
|
|
ir = intref(xr);
|
|
|
|
// CHECK: load i32
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = floatref(ir);
|
|
|
|
// CHECK: load
|
|
|
|
// CHECK: {{bitcast.*to float\*}}
|
|
|
|
// CHECK: load float*
|
|
|
|
fr = floatref(xr);
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = Xref(ir);
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
|
|
|
|
xr = Xref(fr);
|
2010-07-15 05:35:45 +08:00
|
|
|
typedef _Complex float &complex_float_ref;
|
|
|
|
_Complex float cf;
|
|
|
|
_Complex float &cfr = cf;
|
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: bitcast i32*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = complex_float_ref(ir);
|
|
|
|
// CHECK: load float**
|
|
|
|
// CHECK: bitcast float*
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = complex_float_ref(fr);
|
|
|
|
// CHECK: bitcast
|
|
|
|
// CHECK: load float*
|
|
|
|
// CHECK: load float*
|
|
|
|
cfr = complex_float_ref(xr);
|
2010-07-14 07:27:15 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace PR6437 {
|
|
|
|
struct in_addr {};
|
|
|
|
void copy( const struct in_addr &new_addr ) {
|
|
|
|
int addr = (int&)new_addr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace PR7593 {
|
|
|
|
void foo(double &X, char *A) {
|
|
|
|
X = reinterpret_cast<double&>(A[4]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace PR7344 {
|
|
|
|
void serialize_annotatable_id( void*& id )
|
|
|
|
{
|
|
|
|
unsigned long l_id = (unsigned long&)id;
|
|
|
|
}
|
|
|
|
}
|