Merged r157653 through r157895 into branch.
[official-gcc.git] / gcc / testsuite / objc.dg / bitfield-1.m
blob664a0e8d48fc9b3889ae77ac2043cebc73addea7
1 /* Check if bitfield ivars are inherited correctly (i.e., without
2    being "promoted" to ints).  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-do run } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7 #include "../objc-obj-c++-shared/Object1.h"
8 #include <objc/objc.h>
10 extern void abort(void);
12 #define CHECK_IF(expr) if(!(expr)) abort();
14 @interface Base: Object 
16     int full;
17     int full2: 32;
18     int _refs: 8;
19     int field2: 3;
20     unsigned f3: 8;
21     short cc;
22     unsigned g: 16;
23     int r2: 8;
24     int r3: 8;
25     int r4: 2;
26     int r5: 8;
27     char c;
29 - (void)setValues;
30 @end
32 @interface Derived: Base
34     char d;
35     int _field3: 6;
37 - (void)checkValues;
38 @end
40 @implementation Base
41 -(void)setValues {
42   full = 1;
43   full2 = 2;
44   _refs = 3;
45   field2 = 1;
46   f3 = 6;
47   cc = 7;
48   g = 8;
49   r2 = 9;
50   r3 = 10;
51   r4 = 1;
52   r5 = 12;
53   c = 13;
55 @end
57 @implementation Derived
58 -(void)checkValues {
59   CHECK_IF(full == 1);
60   CHECK_IF(full2 == 2);
61   CHECK_IF(_refs == 3);
62   CHECK_IF(field2 == 1);
63   CHECK_IF(f3 == 6);
64   CHECK_IF(cc == 7);
65   CHECK_IF(g == 8);
66   CHECK_IF(r2 == 9);
67   CHECK_IF(r3 == 10);
68   CHECK_IF(r4 == 1);
69   CHECK_IF(r5 == 12);
70   CHECK_IF(c == 13);
72 @end
74 int main(void) {
75   Derived *obj = [[Derived alloc] init];
77   [obj setValues];
78   [obj checkValues];
80   return 0;
83 #include "../objc-obj-c++-shared/Object1-implementation.h"