Fix unused warnings.
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc / execute / accessing_ivars.m
blobdbde8cd11dd97e2497429bbc69bc98f0c711bc04
1 /* Contributed by Nicola Pero - Thu Mar  8 16:27:46 CET 2001 */
2 #include <stdlib.h>
3 #import "../../objc-obj-c++-shared/Object1.h"
4 #include <objc/objc-api.h>
6 /* Test that by using -> we can access ivars of other objects of the same 
7    class */
9 @interface TestClass : Object
11   int value;
13 - (int) value;
14 - (int) setValue: (int)number;
15 - (void) takeValueFrom: (TestClass *)object;
16 @end
18 @implementation TestClass : Object
20   int value;
22 - (int) value
23
24   return value;
26 - (int) setValue: (int)number
28   value = number; 
30 - (void) takeValueFrom: (TestClass *)object
32   value = object->value;
34 @end
36 int main (void)
38   TestClass *a;
39   TestClass *b;
41   a = [TestClass new];
42   [a setValue: 10];
43   
44   b = [TestClass new];
45   [b setValue: -10];
47   [b takeValueFrom: a];
49   if ([b value] != [a value])
50     {
51       abort ();
52     }
54   return 0;