New objc tests for bitfield enumeration ivars
[gcc.git] / gcc / testsuite / objc / execute / enumeration-1.m
1 /* Contributed by Nicola Pero - Wed Dec 5 17:12:40 GMT 2001 */
2 #include <objc/objc.h>
3 #include <objc/Object.h>
4
5 /* Test using a bitfield enumeration ivar. */
6
7 typedef enum
8 {
9 black,
10 white
11 } color;
12
13 @interface TestClass: Object
14 {
15 color c:2;
16 }
17 - (color)color;
18 - (void)setColor: (color)a;
19 @end
20
21 @implementation TestClass
22 - (color)color
23 {
24 return c;
25 }
26 - (void)setColor: (color)a
27 {
28 c = a;
29 }
30 @end
31
32
33 int main (void)
34 {
35 TestClass *c;
36
37 c = [TestClass new];
38
39 [c setColor: black];
40 [c setColor: white];
41 [c setColor: black];
42 if ([c color] != black)
43 {
44 abort ();
45 }
46
47
48 return 0;
49 }