summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc/execute/root_methods.m
blob: d9085ae7b0408774dc812dfb87fa3cc628c025a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Contributed by Nicola Pero - Thu Mar  8 16:27:46 CET 2001 */

#import "../../objc-obj-c++-shared/next-mapping.h"
#import <objc/objc.h>

/* Test that instance methods of root classes are available as class 
   methods to other classes as well */

@interface RootClass
{
  Class isa;
}
- (id) self;
@end

@implementation RootClass
- (id) self
{
  return self;
}
#ifdef __NEXT_RUNTIME__                                   
+ initialize { return self; }
#endif
@end

@interface NormalClass : RootClass
@end

@implementation NormalClass : RootClass
@end

int main (void)
{
  Class normal = objc_get_class ("NormalClass");

  if (normal == Nil)
    {
      abort ();
    }

  if ([NormalClass self] != normal)
    {
      abort ();
    }

  return 0;
}