OSDN Git Service

PR testsuite/23611, PR testsuite/23615
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / obj-c++.dg / bitfield-2.mm
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
6 #include <objc/Object.h>
7 #include <stdlib.h>
8
9 #define CHECK_IF(expr) if(!(expr)) abort();
10
11 @interface Base: Object 
12 {
13     int full;
14     int full2: 32;
15     int _refs: 8;
16     int field2: 3;
17     unsigned f3: 8;
18     short cc;
19     unsigned g: 16;
20     int r2: 8;
21     int r3: 8;
22     int r4: 2;
23     int r5: 8;
24     char c;
25 }
26 - (void)setValues;
27 @end
28
29 @interface Derived: Base
30 {
31     char d;
32     int _field3: 6;
33 }
34 - (void)checkValues;
35 @end
36
37 @implementation Base
38 -(void)setValues {
39   full = 1;
40   full2 = 2;
41   _refs = 3;
42   field2 = 1;
43   f3 = 6;
44   cc = 7;
45   g = 8;
46   r2 = 9;
47   r3 = 10;
48   r4 = 1;
49   r5 = 12;
50   c = 13;
51 }
52 @end
53
54 @implementation Derived
55 -(void)checkValues {
56   CHECK_IF(full == 1);
57   CHECK_IF(full2 == 2);
58   CHECK_IF(_refs == 3);
59   CHECK_IF(field2 == 1);
60   CHECK_IF(f3 == 6);
61   CHECK_IF(cc == 7);
62   CHECK_IF(g == 8);
63   CHECK_IF(r2 == 9);
64   CHECK_IF(r3 == 10);
65   CHECK_IF(r4 == 1);
66   CHECK_IF(r5 == 12);
67   CHECK_IF(c == 13);
68 }
69 @end
70
71 int main(void) {
72   Derived *obj = [[Derived alloc] init];
73
74   [obj setValues];
75   [obj checkValues];
76
77   return 0;
78 }