xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/bitfield-1.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
3*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface Object
6*f4a2713aSLionel Sambuc- (id) alloc;
7*f4a2713aSLionel Sambuc- (id) init;
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambucextern void abort(void);
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc#define CHECK_IF(expr) if(!(expr)) abort();
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc@interface Base: Object
15*f4a2713aSLionel Sambuc{
16*f4a2713aSLionel Sambuc    int full;
17*f4a2713aSLionel Sambuc    int full2: 32;
18*f4a2713aSLionel Sambuc    int _refs: 8;
19*f4a2713aSLionel Sambuc    int field2: 3;
20*f4a2713aSLionel Sambuc    unsigned f3: 8;
21*f4a2713aSLionel Sambuc    short cc;
22*f4a2713aSLionel Sambuc    unsigned g: 16;
23*f4a2713aSLionel Sambuc    int r2: 8;
24*f4a2713aSLionel Sambuc    int r3: 8;
25*f4a2713aSLionel Sambuc    int r4: 2;
26*f4a2713aSLionel Sambuc    int r5: 8;
27*f4a2713aSLionel Sambuc    char c;
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc- (void)setValues;
30*f4a2713aSLionel Sambuc@end
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc@interface Derived: Base
33*f4a2713aSLionel Sambuc{
34*f4a2713aSLionel Sambuc    char d;
35*f4a2713aSLionel Sambuc    int _field3: 6;
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc- (void)checkValues;
38*f4a2713aSLionel Sambuc@end
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc@implementation Base
41*f4a2713aSLionel Sambuc-(void)setValues {
42*f4a2713aSLionel Sambuc  full = 1;
43*f4a2713aSLionel Sambuc  full2 = 2;
44*f4a2713aSLionel Sambuc  _refs = 3;
45*f4a2713aSLionel Sambuc  field2 = 1;
46*f4a2713aSLionel Sambuc  f3 = 6;
47*f4a2713aSLionel Sambuc  cc = 7;
48*f4a2713aSLionel Sambuc  g = 8;
49*f4a2713aSLionel Sambuc  r2 = 9;
50*f4a2713aSLionel Sambuc  r3 = 10;
51*f4a2713aSLionel Sambuc  r4 = 1;
52*f4a2713aSLionel Sambuc  r5 = 12;
53*f4a2713aSLionel Sambuc  c = 13;
54*f4a2713aSLionel Sambuc}
55*f4a2713aSLionel Sambuc@end
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc@implementation Derived
58*f4a2713aSLionel Sambuc-(void)checkValues {
59*f4a2713aSLionel Sambuc  CHECK_IF(full == 1);
60*f4a2713aSLionel Sambuc  CHECK_IF(full2 == 2);
61*f4a2713aSLionel Sambuc  CHECK_IF(_refs == 3);
62*f4a2713aSLionel Sambuc  CHECK_IF(field2 == 1);
63*f4a2713aSLionel Sambuc  CHECK_IF(f3 == 6);
64*f4a2713aSLionel Sambuc  CHECK_IF(cc == 7);
65*f4a2713aSLionel Sambuc  CHECK_IF(g == 8);
66*f4a2713aSLionel Sambuc  CHECK_IF(r2 == 9);
67*f4a2713aSLionel Sambuc  CHECK_IF(r3 == 10);
68*f4a2713aSLionel Sambuc  CHECK_IF(r4 == 1);
69*f4a2713aSLionel Sambuc  CHECK_IF(r5 == 12);
70*f4a2713aSLionel Sambuc  CHECK_IF(c == 13);
71*f4a2713aSLionel Sambuc}
72*f4a2713aSLionel Sambuc@end
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel Sambucint main(void) {
75*f4a2713aSLionel Sambuc  Derived *obj = [[Derived alloc] init];
76*f4a2713aSLionel Sambuc
77*f4a2713aSLionel Sambuc  [obj setValues];
78*f4a2713aSLionel Sambuc  [obj checkValues];
79*f4a2713aSLionel Sambuc
80*f4a2713aSLionel Sambuc  return 0;
81*f4a2713aSLionel Sambuc}
82