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" } { "" } } */
9 #include "../objc-obj-c++-shared/runtime.h"
11 extern void abort(void);
12 extern int strcmp(const char *, const char *);
13 #define CHECK_IF(expr) if(!(expr)) abort()
16 - (const char *) method4;
21 + (const char *) method2;
24 @interface Derived: Root
25 - (const char *) method1;
26 - (const char *) method2;
27 - (const char *) method3;
30 @interface Root (Categ)
31 - (const char *) method3;
34 @implementation Root (Categ)
35 - (const char *) method3 { return "Root(Categ)::-method3"; }
36 - (const char *) method4 { return "Root(Categ)::-method4"; }
39 @implementation Derived
40 - (const char *) method1 { return "Derived::-method1"; }
41 - (const char *) method2 { return "Derived::-method2"; }
42 - (const char *) method3 { return "Derived::-method3"; }
46 + initialize { return self; }
47 - (const char *) method1 { return "Root::-method1"; }
48 + (const char *) method2 { return "Root::+method2"; }
53 Class obj = objc_getClass("Derived");
55 /* None of the following should elicit compiler-time warnings. */
57 CHECK_IF(!strcmp([Root method1], "Root::-method1"));
58 CHECK_IF(!strcmp([Root method2], "Root::+method2"));
59 CHECK_IF(!strcmp([Root method3], "Root(Categ)::-method3"));
60 CHECK_IF(!strcmp([Root method4], "Root(Categ)::-method4"));
61 CHECK_IF(!strcmp([Derived method1], "Root::-method1"));
62 CHECK_IF(!strcmp([Derived method2], "Root::+method2"));
63 CHECK_IF(!strcmp([Derived method3], "Root(Categ)::-method3"));
64 CHECK_IF(!strcmp([Derived method4], "Root(Categ)::-method4"));
65 CHECK_IF(!strcmp([obj method1], "Root::-method1"));
66 CHECK_IF(!strcmp([obj method2], "Root::+method2"));
67 CHECK_IF(!strcmp([obj method3], "Root(Categ)::-method3"));
68 CHECK_IF(!strcmp([obj method4], "Root(Categ)::-method4"));