OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [method-13.m] - Blame information for rev 315

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 309 jeremybenn
/* 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>.  */
5
/* { dg-do run } */
6
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
7
 
8
#include <objc/objc.h>
9
 
10
#ifdef __NEXT_RUNTIME__
11
#define OBJC_GETCLASS objc_getClass
12
#else
13
#define OBJC_GETCLASS objc_get_class
14
#endif
15
 
16
extern void abort(void);
17
extern int strcmp(const char *, const char *);
18
#define CHECK_IF(expr) if(!(expr)) abort()
19
 
20
@protocol Proto
21
- (const char *) method4;
22
@end
23
 
24
@interface Root
25
{ Class isa; }
26
+ (const char *) method2;
27
@end
28
 
29
@interface Derived: Root
30
- (const char *) method1;
31
- (const char *) method2;
32
- (const char *) method3;
33
@end
34
 
35
@interface Root (Categ)
36
- (const char *) method3;
37
@end
38
 
39
@implementation Root (Categ)
40
- (const char *) method3 { return "Root(Categ)::-method3"; }
41
- (const char *) method4 { return "Root(Categ)::-method4"; }
42
@end
43
 
44
@implementation Derived
45
- (const char *) method1 { return "Derived::-method1"; }
46
- (const char *) method2 { return "Derived::-method2"; }
47
- (const char *) method3 { return "Derived::-method3"; }
48
@end
49
 
50
@implementation Root
51
#ifdef __NEXT_RUNTIME__
52
+ initialize { return self; }
53
#endif
54
- (const char *) method1 { return "Root::-method1"; }
55
+ (const char *) method2 { return "Root::+method2"; }
56
@end
57
 
58
int main(void)
59
{
60
  Class obj = OBJC_GETCLASS("Derived");
61
 
62
  /* None of the following should elicit compiler-time warnings.  */
63
 
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"));
76
 
77
  return 0;
78
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.