2010-02-02 11:23:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin10 | FileCheck %s
|
2009-11-27 12:56:40 +08:00
|
|
|
|
2010-02-02 11:37:46 +08:00
|
|
|
struct A { int a; int b; };
|
2009-11-27 12:56:40 +08:00
|
|
|
struct B { int b; };
|
|
|
|
struct C : B, A { };
|
|
|
|
|
2010-02-02 11:32:35 +08:00
|
|
|
// Zero init.
|
|
|
|
namespace ZeroInit {
|
|
|
|
// CHECK: @_ZN8ZeroInit1aE = global i64 -1
|
|
|
|
int A::* a;
|
|
|
|
|
|
|
|
// CHECK: @_ZN8ZeroInit2aaE = global [2 x i64] [i64 -1, i64 -1]
|
|
|
|
int A::* aa[2];
|
|
|
|
|
|
|
|
// CHECK: @_ZN8ZeroInit3aaaE = global [2 x [2 x i64]] {{\[}}[2 x i64] [i64 -1, i64 -1], [2 x i64] [i64 -1, i64 -1]]
|
|
|
|
int A::* aaa[2][2];
|
|
|
|
|
|
|
|
// CHECK: @_ZN8ZeroInit1bE = global i64 -1,
|
|
|
|
int A::* b = 0;
|
2010-02-02 13:17:25 +08:00
|
|
|
|
|
|
|
// CHECK: @_ZN8ZeroInit2saE = global %struct.anon { i64 -1 }
|
|
|
|
struct {
|
|
|
|
int A::*a;
|
|
|
|
} sa;
|
|
|
|
|
2010-02-05 14:58:06 +08:00
|
|
|
// CHECK: @_ZN8ZeroInit3ssaE =
|
|
|
|
// CHECK: [2 x i64] [i64 -1, i64 -1]
|
2010-02-02 13:17:25 +08:00
|
|
|
struct {
|
|
|
|
int A::*aa[2];
|
|
|
|
} ssa[2];
|
|
|
|
|
|
|
|
// CHECK: @_ZN8ZeroInit2ssE = global %1 { %struct.anon { i64 -1 } }
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
int A::*pa;
|
|
|
|
} s;
|
|
|
|
} ss;
|
2010-02-02 11:37:46 +08:00
|
|
|
}
|
2010-02-02 11:32:35 +08:00
|
|
|
|
2010-02-02 11:37:46 +08:00
|
|
|
// PR5674
|
|
|
|
namespace PR5674 {
|
|
|
|
// CHECK: @_ZN6PR56742pbE = global i64 4
|
|
|
|
int A::*pb = &A::b;
|
2010-02-02 11:32:35 +08:00
|
|
|
}
|
|
|
|
|
2010-02-02 11:23:38 +08:00
|
|
|
// Casts.
|
|
|
|
namespace Casts {
|
|
|
|
|
2009-11-27 12:56:40 +08:00
|
|
|
int A::*pa;
|
|
|
|
int C::*pc;
|
|
|
|
|
|
|
|
void f() {
|
2010-02-02 11:23:38 +08:00
|
|
|
// CHECK: store i64 -1, i64* @_ZN5Casts2paE
|
2009-11-27 12:56:40 +08:00
|
|
|
pa = 0;
|
|
|
|
|
|
|
|
// CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 4
|
2010-02-02 11:23:38 +08:00
|
|
|
// CHECK: store i64 [[ADJ]], i64* @_ZN5Casts2pcE
|
2009-11-27 12:56:40 +08:00
|
|
|
pc = pa;
|
|
|
|
|
|
|
|
// CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub i64 {{.*}}, 4
|
2010-02-02 11:23:38 +08:00
|
|
|
// CHECK: store i64 [[ADJ]], i64* @_ZN5Casts2paE
|
2009-11-27 12:56:40 +08:00
|
|
|
pa = static_cast<int A::*>(pc);
|
|
|
|
}
|
2010-02-02 11:23:38 +08:00
|
|
|
|
|
|
|
}
|
2010-02-02 11:37:46 +08:00
|
|
|
|
|
|
|
// Comparisons
|
|
|
|
namespace Comparisons {
|
|
|
|
void f() {
|
|
|
|
int A::*a;
|
|
|
|
|
|
|
|
// CHECK: icmp ne i64 {{.*}}, -1
|
|
|
|
if (a) { }
|
|
|
|
|
|
|
|
// CHECK: icmp ne i64 {{.*}}, -1
|
|
|
|
if (a != 0) { }
|
|
|
|
|
|
|
|
// CHECK: icmp ne i64 -1, {{.*}}
|
|
|
|
if (0 != a) { }
|
|
|
|
|
|
|
|
// CHECK: icmp eq i64 {{.*}}, -1
|
|
|
|
if (a == 0) { }
|
|
|
|
|
|
|
|
// CHECK: icmp eq i64 -1, {{.*}}
|
|
|
|
if (0 == a) { }
|
|
|
|
}
|
|
|
|
}
|