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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [method-13.m] - Blame information for rev 708

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

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

powered by: WebSVN 2.1.0

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