Fix unused warnings.
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc / execute / class-14.m
blobe04452e527bf5d8e350005530d40f7e17dae342d
1 /* Contributed by Nicola Pero - Tue Mar  6 23:05:53 CET 2001 */
3 #include "../../objc-obj-c++-shared/next-mapping.h"
4 #include <objc/objc.h>
5 #include <objc/objc-api.h>
7 /* Tests creating a root class and a subclass with a class accessor
8    methods and a subclass overriding the superclass' implementation,
9    and using self to call another method of itself */
11 @interface RootClass
13   Class isa;
15 @end
17 @implementation RootClass
18 #ifdef __NEXT_RUNTIME__                                   
19 + initialize { return self; }
20 #endif
21 @end
23 static int class_variable = 0;
25 @interface SubClass : RootClass
26 + (void) setState: (int)number;
27 + (int) state;
28 @end
30 @implementation SubClass
31 + (void) setState: (int)number
33   class_variable = number;
35 + (int) state
37   return class_variable;
39 @end
41 @interface SubSubClass : SubClass
42 + (int) shift;
43 @end
45 @implementation SubSubClass
46 + (int) state
48   return class_variable + [self shift];
50 + (int) shift
52   return 1;
54 @end
56 #include "class-tests-1.h"
57 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
58 #include "class-tests-2.h"
60 int main (void)
62   Class class, sub_class;
64   test_class_with_superclass ("SubClass", "RootClass");
65   test_that_class_has_class_method ("SubClass", @selector (setState:));
66   test_that_class_has_class_method ("SubClass", @selector (state));
68   test_class_with_superclass ("SubSubClass", "SubClass");
69   test_that_class_has_class_method ("SubSubClass", @selector (setState:));
70   test_that_class_has_class_method ("SubSubClass", @selector (state));
71   test_that_class_has_class_method ("SubSubClass", @selector (shift));
72   
73   class = objc_lookup_class ("SubClass");
74   test_accessor_method (class, 0, -1, -1, 1, 1);
76   sub_class = objc_lookup_class ("SubSubClass");
77   class_variable = 0;
78   test_accessor_method (sub_class, 1, -1, 0, 1, 2);
80   return 0;