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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [obj-c++.dg/] [method-19.mm] - Blame information for rev 154

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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