OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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