Added support for the 64-bit Apple Objective-C runtime
[official-gcc.git] / gcc / testsuite / objc / execute / accessing_ivars.m
blobe4c9cf4cd42977c121d6a08cedb3bfe48a97eaab
1 /* Contributed by Nicola Pero - Thu Mar  8 16:27:46 CET 2001 */
2 #include <stdlib.h>
3 #ifndef __NEXT_RUNTIME__
4 #include <objc/objc-api.h>
5 #endif
6 #include "../../objc-obj-c++-shared/Object1.h"
8 /* Test that by using -> we can access ivars of other objects of the same 
9    class */
11 @interface TestClass : Object
13   int value;
15 - (int) value;
16 - (int) setValue: (int)number;
17 - (void) takeValueFrom: (TestClass *)object;
18 @end
20 @implementation TestClass : Object
22   int value;
24 - (int) value
25
26   return value;
28 - (int) setValue: (int)number
30   value = number; 
32 - (void) takeValueFrom: (TestClass *)object
34   value = object->value;
36 @end
38 int main (void)
40   TestClass *a;
41   TestClass *b;
43   a = [TestClass new];
44   [a setValue: 10];
45   
46   b = [TestClass new];
47   [b setValue: -10];
49   [b takeValueFrom: a];
51   if ([b value] != [a value])
52     {
53       abort ();
54     }
56   return 0;
58 #include "../../objc-obj-c++-shared/Object1-implementation.h"