Debian Codegraph @

gcc/testsuite/objc/execute/class_self-1.m

raw
1 /* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
2 #include <objc/objc.h>
3
4 /* Test calling a class method when there is an instance method
5 with conflicting types */
6
7 /* This class should be unused but on broken compilers its instance
8 method might get picked up and used instead of the class method of
9 another class ! */
10 struct d
11 {
12 int a;
13 };
14
15 @interface UnusedClass
16 {
17 Class isa;
18 }
19 - (struct d) method;
20 @end
21
22 @implementation UnusedClass
23 - (struct d) method
24 {
25 struct d u;
26 u.a = 0;
27
28 return u;
29 }
30 @end
31
32 /* The real class */
33 @interface TestClass
34 {
35 Class isa;
36 }
37 + (void) test;
38 + (int) method;
39 @end
40
41 @implementation TestClass
42 + (void) test
43 {
44 if ([self method] != 4)
45 {
46 abort ();
47 }
48 }
49
50 + (int) method
51 {
52 return 4;
53 }
54 + initialize { return self; }
55 @end
56
57
58 int main (void)
59 {
60 [TestClass test];
61
62 return 0;
63 }