1 /* Test if instance methods of root classes are used as class methods, if no
2 "real" methods are found. For receivers of type 'id' and 'Class', all
3 root classes must be considered. */
4 /* Author: Ziemowit Laski <zlaski@apple.com>. */
6 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
10 #ifdef __NEXT_RUNTIME__
11 #define OBJC_GETCLASS objc_getClass
13 #define OBJC_GETCLASS objc_get_class
16 extern void abort(void);
17 extern int strcmp(const char *, const char *);
18 #define CHECK_IF(expr) if(!(expr)) abort()
21 - (const char *) method4;
26 + (const char *) method2;
29 @interface Derived: Root
30 - (const char *) method1;
31 - (const char *) method2;
32 - (const char *) method3;
35 @interface Root (Categ)
36 - (const char *) method3;
39 @implementation Root (Categ)
40 - (const char *) method3 { return "Root(Categ)::-method3"; }
41 - (const char *) method4 { return "Root(Categ)::-method4"; }
44 @implementation Derived
45 - (const char *) method1 { return "Derived::-method1"; }
46 - (const char *) method2 { return "Derived::-method2"; }
47 - (const char *) method3 { return "Derived::-method3"; }
51 #ifdef __NEXT_RUNTIME__
52 + initialize { return self; }
54 - (const char *) method1 { return "Root::-method1"; }
55 + (const char *) method2 { return "Root::+method2"; }
60 Class obj = OBJC_GETCLASS("Derived");
62 /* None of the following should elicit compiler-time warnings. */
64 CHECK_IF(!strcmp([Root method1], "Root::-method1"));
65 CHECK_IF(!strcmp([Root method2], "Root::+method2"));
66 CHECK_IF(!strcmp([Root method3], "Root(Categ)::-method3"));
67 CHECK_IF(!strcmp([Root method4], "Root(Categ)::-method4"));
68 CHECK_IF(!strcmp([Derived method1], "Root::-method1"));
69 CHECK_IF(!strcmp([Derived method2], "Root::+method2"));
70 CHECK_IF(!strcmp([Derived method3], "Root(Categ)::-method3"));
71 CHECK_IF(!strcmp([Derived method4], "Root(Categ)::-method4"));
72 CHECK_IF(!strcmp([obj method1], "Root::-method1"));
73 CHECK_IF(!strcmp([obj method2], "Root::+method2"));
74 CHECK_IF(!strcmp([obj method3], "Root(Categ)::-method3"));
75 CHECK_IF(!strcmp([obj method4], "Root(Categ)::-method4"));