/* Test if instance methods of root classes are used as class methods, if no
|
/* Test if instance methods of root classes are used as class methods, if no
|
"real" methods are found. For receivers of type 'id' and 'Class', all
|
"real" methods are found. For receivers of type 'id' and 'Class', all
|
root classes must be considered. */
|
root classes must be considered. */
|
/* Author: Ziemowit Laski . */
|
/* Author: Ziemowit Laski . */
|
/* { dg-do run } */
|
/* { dg-do run } */
|
|
|
#include
|
#include
|
|
|
#ifdef __NEXT_RUNTIME__
|
#ifdef __NEXT_RUNTIME__
|
#include
|
#include
|
#define OBJC_GETCLASS objc_getClass
|
#define OBJC_GETCLASS objc_getClass
|
#else
|
#else
|
#include
|
#include
|
#define OBJC_GETCLASS objc_get_class
|
#define OBJC_GETCLASS objc_get_class
|
#endif
|
#endif
|
|
|
#include
|
#include
|
#include
|
#include
|
|
|
#define CHECK_IF(expr) if(!(expr)) abort()
|
#define CHECK_IF(expr) if(!(expr)) abort()
|
|
|
@protocol Proto
|
@protocol Proto
|
- (const char *) method4;
|
- (const char *) method4;
|
@end
|
@end
|
|
|
@interface Root
|
@interface Root
|
{ Class isa; }
|
{ Class isa; }
|
+ (const char *) method2;
|
+ (const char *) method2;
|
@end
|
@end
|
|
|
@interface Derived: Root
|
@interface Derived: Root
|
- (const char *) method1;
|
- (const char *) method1;
|
- (const char *) method2;
|
- (const char *) method2;
|
- (const char *) method3;
|
- (const char *) method3;
|
@end
|
@end
|
|
|
@interface Root (Categ)
|
@interface Root (Categ)
|
- (const char *) method3;
|
- (const char *) method3;
|
@end
|
@end
|
|
|
@implementation Root (Categ)
|
@implementation Root (Categ)
|
- (const char *) method3 { return "Root(Categ)::-method3"; }
|
- (const char *) method3 { return "Root(Categ)::-method3"; }
|
- (const char *) method4 { return "Root(Categ)::-method4"; }
|
- (const char *) method4 { return "Root(Categ)::-method4"; }
|
@end
|
@end
|
|
|
@implementation Derived
|
@implementation Derived
|
- (const char *) method1 { return "Derived::-method1"; }
|
- (const char *) method1 { return "Derived::-method1"; }
|
- (const char *) method2 { return "Derived::-method2"; }
|
- (const char *) method2 { return "Derived::-method2"; }
|
- (const char *) method3 { return "Derived::-method3"; }
|
- (const char *) method3 { return "Derived::-method3"; }
|
@end
|
@end
|
|
|
@implementation Root
|
@implementation Root
|
#ifdef __NEXT_RUNTIME__
|
#ifdef __NEXT_RUNTIME__
|
+ initialize { return self; }
|
+ initialize { return self; }
|
#endif
|
#endif
|
- (const char *) method1 { return "Root::-method1"; }
|
- (const char *) method1 { return "Root::-method1"; }
|
+ (const char *) method2 { return "Root::+method2"; }
|
+ (const char *) method2 { return "Root::+method2"; }
|
@end
|
@end
|
|
|
int main(void)
|
int main(void)
|
{
|
{
|
Class obj = OBJC_GETCLASS("Derived");
|
Class obj = OBJC_GETCLASS("Derived");
|
|
|
/* None of the following should elicit compiler-time warnings. */
|
/* None of the following should elicit compiler-time warnings. */
|
|
|
CHECK_IF(!strcmp([Root method1], "Root::-method1"));
|
CHECK_IF(!strcmp([Root method1], "Root::-method1"));
|
CHECK_IF(!strcmp([Root method2], "Root::+method2"));
|
CHECK_IF(!strcmp([Root method2], "Root::+method2"));
|
CHECK_IF(!strcmp([Root method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([Root method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([Root method4], "Root(Categ)::-method4"));
|
CHECK_IF(!strcmp([Root method4], "Root(Categ)::-method4"));
|
CHECK_IF(!strcmp([Derived method1], "Root::-method1"));
|
CHECK_IF(!strcmp([Derived method1], "Root::-method1"));
|
CHECK_IF(!strcmp([Derived method2], "Root::+method2"));
|
CHECK_IF(!strcmp([Derived method2], "Root::+method2"));
|
CHECK_IF(!strcmp([Derived method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([Derived method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([Derived method4], "Root(Categ)::-method4"));
|
CHECK_IF(!strcmp([Derived method4], "Root(Categ)::-method4"));
|
CHECK_IF(!strcmp([obj method1], "Root::-method1"));
|
CHECK_IF(!strcmp([obj method1], "Root::-method1"));
|
CHECK_IF(!strcmp([obj method2], "Root::+method2"));
|
CHECK_IF(!strcmp([obj method2], "Root::+method2"));
|
CHECK_IF(!strcmp([obj method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([obj method3], "Root(Categ)::-method3"));
|
CHECK_IF(!strcmp([obj method4], "Root(Categ)::-method4"));
|
CHECK_IF(!strcmp([obj method4], "Root(Categ)::-method4"));
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|