Debian Codegraph @

gcc/testsuite/objc.dg/property/synthesize-10.m

raw
1 /* Contributed by Nicola Pero <[email protected]>, November 2010. */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
5 /* Test @synthesize with bitfield instance variables. */
6
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
10
11 @interface MyRootClass
12 {
13 Class isa;
14 int countA : 2;
15 int countB : 3;
16 int countC : 4;
17 }
18 + (id) initialize;
19 + (id) alloc;
20 - (id) init;
21 @property (nonatomic) int countA;
22 @property (nonatomic) int countB;
23 @property (nonatomic) int countC;
24 @end
25
26 @implementation MyRootClass
27 + (id) initialize { return self; }
28 + (id) alloc { return class_createInstance (self, 0); }
29 - (id) init { return self; }
30 @synthesize countA;
31 @synthesize countB;
32 @synthesize countC;
33 @end
34
35 int main (void)
36 {
37 MyRootClass *object = [[MyRootClass alloc] init];
38
39 object.countA = 1;
40 object.countB = 3;
41 object.countC = 4;
42
43 if (object.countA != 1)
44 abort ();
45
46 if (object.countB != 3)
47 abort ();
48
49 if (object.countC != 4)
50 abort ();
51
52 return 0;
53 }