FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / objc / execute / class_self-2.m
blobe64fcf9fff4906b5b29fbdd95243999dd830f9f9
1 /* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
2 #include <objc/objc.h>
4 /* Test calling a class method on self where self has been redefined
5    to be another class - the call requires a cast */
8 /* The first class */
9 struct d
11   int a;
14 @interface ClassA
16   Class isa;
18 + (Class) class;
19 + (struct d) method;
20 @end
22 @implementation ClassA
23 + (Class) class
25   return self;
28 + (struct d) method
30   struct d u;
31   u.a = 5;
32   
33   return u;
35 @end
37 /* The second class */
38 @interface TestClass
40   Class isa;
42 + (void) test;
43 @end
45 @implementation TestClass
46 + (void) test
48   self = [ClassA class];
49   
51   if ([(Class)self method].a != 5)
52     {
53       abort ();
54     }
57 @end
60 int main (void)
62   [TestClass test];
64   return 0;