In gcc/: 2010-10-30 Nicola Pero <nicola.pero@meta-innovation.com>
[platform/upstream/gcc.git] / gcc / testsuite / objc.dg / property / at-property-8.m
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
2 /* { dg-do run } */
3
4 /* Test the property syntax with non-synthesized setter/getter
5    and with a non-standard name for the setter.  */
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 a;
15 }
16 @property (setter = writeA:) int a;
17 + (id) initialize;
18 + (id) alloc;
19 - (id) init;
20 @end
21
22 @implementation MyRootClass
23 + (id) initialize { return self; }
24 + (id) alloc { return class_createInstance (self, 0); }
25 - (id) init { return self; }
26
27 - (int) a
28 {
29   return a;
30 }
31 - (void) writeA: (int)value
32 {
33   a = value;
34 }
35 @end
36
37 int main (void)
38 {
39   MyRootClass *object = [[MyRootClass alloc] init];
40
41   object.a = 14;
42
43   if (object.a != 14)
44     abort ();
45
46   object.a = 23;
47
48   if (object.a != 23)
49     abort ();
50
51   object.a = 78;
52
53   if (object.a != 78)
54     abort ();
55
56   return 0;
57 }