Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc.dg / property / dotsyntax-2.m
blob03e49aebc5279b6536b2f150ca80b6b4cc977769
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
5 /* Test the 'dot syntax' without a declarated property.  This tests the case where
6    only the setter (or only the getter) exists.  */
8 #include <stdlib.h>
9 #include <objc/objc.h>
10 #include <objc/runtime.h>
12 @interface MyRootClass
14   Class isa;
15   int a;
16   id b;
18 + (id) initialize;
19 + (id) alloc;
20 - (id) init;
21 - (int) a;
22 - (void) setCount: (int)value;
23 - (id) b;
24 - (void) setNext: (id)value;
25 @end
27 @implementation MyRootClass
28 + (id) initialize { return self; }
29 + (id) alloc { return class_createInstance (self, 0); }
30 - (id) init { return self; }
31 - (int) a
33   return a;
35 - (void) setCount: (int)value
37   a = value;
39 - (id) b
41   return b;
43 - (void) setNext: (id)value
45   b = value;
47 @end
49 int main (void)
51   MyRootClass *object = [[MyRootClass alloc] init];
53   /* This should work because -setCount: exists (even if -count does
54      not).  */
55   object.count = 40;
57   /* This should work because -a exists (even if -setA: does not).  */
58   if (object.a != 40)
59     abort ();
61   /* This should work because -setNext: exists (even if -next does
62      not).  */
63   object.next = object;
65   /* This should work because -b exists (even if -setB: does not).  */
66   if (object.b != object)
67     abort ();
69   return 0;