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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [property/] [dotsyntax-12.mm] - Blame information for rev 820

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

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , November 2010.  */
2
/* { dg-do run } */
3
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
 
5
/* Test looking up a setter or getter which are in a protocol attached
6
   to a category of a superclass.  */
7
 
8
#include 
9
#include 
10
#include 
11
 
12
static int c;
13
 
14
@interface MyRootClass
15
{
16
  Class isa;
17
  int a;
18
}
19
+ (id) initialize;
20
+ (id) alloc;
21
- (id) init;
22
@end
23
 
24
@implementation MyRootClass
25
+ (id) initialize { return self; }
26
+ (id) alloc { return class_createInstance (self, 0); }
27
- (id) init { return self; }
28
@end
29
 
30
@protocol count
31
- (int) count;
32
- (void) setCount: (int)count;
33
@end
34
 
35
@protocol classCount
36
+ (int) classCount;
37
+ (void) setClassCount: (int)count;
38
@end
39
 
40
@interface MyRootClass (Category) 
41
@end
42
 
43
@implementation MyRootClass (Category)
44
- (int) count
45
{
46
  return a;
47
}
48
- (void) setCount: (int)count
49
{
50
  a = count;
51
}
52
+ (int) classCount
53
{
54
  return c;
55
}
56
+ (void) setClassCount: (int)count
57
{
58
  c = count;
59
}
60
@end
61
 
62
@interface MySubClass : MyRootClass
63
+ (int) testMe;
64
- (int) testMe;
65
@end
66
 
67
@implementation MySubClass
68
- (int) testMe
69
{
70
  self.count = 400;
71
  if (self.count != 400)
72
    abort ();
73
 
74
  return self.count;
75
}
76
+ (int) testMe
77
{
78
  self.classCount = 4000;
79
  if (self.classCount != 4000)
80
    abort ();
81
 
82
  return self.classCount;
83
}
84
@end
85
 
86
int main (void)
87
{
88
  MySubClass *object = [[MySubClass alloc] init];
89
 
90
  object.count = 44;
91
  if (object.count != 44)
92
    abort ();
93
 
94
  MySubClass.classCount = 40;
95
  if (MySubClass.classCount != 40)
96
    abort ();
97
 
98
  if ([object testMe] != 400)
99
    abort ();
100
 
101
  if ([MySubClass testMe] != 4000)
102
    abort ();
103
 
104
  return 0;
105
}

powered by: WebSVN 2.1.0

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