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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [property/] [at-property-27.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , December 2010.  */
2
/* { dg-do run } */
3
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
 
5
/* Test overriding a readonly @property with a readwrite one in a class extension.  */
6
 
7
#include 
8
#include 
9
#include 
10
 
11
@interface MyRootClass
12
{
13
  Class isa;
14
}
15
+ (id) initialize;
16
+ (id) alloc;
17
- (id) init;
18
@end
19
 
20
@implementation MyRootClass
21
+ (id) initialize { return self; }
22
+ (id) alloc { return class_createInstance (self, 0); }
23
- (id) init { return self; }
24
@end
25
 
26
@protocol count2
27
/* Use a different getters/setters, so that the only way to compile
28
   object.countX is to find the actual @property.  */
29
@property (readonly, getter=number2) int count2;
30
@end
31
 
32
@interface MySubClass : MyRootClass
33
{
34
  int count1;
35
  int count2;
36
}
37
@property (readonly, getter=number1) int count1;
38
@end
39
 
40
@interface MySubClass ()
41
@property (readwrite, getter=number1, setter=setNumber1:) int count1;
42
@end
43
 
44
@interface MySubClass ()  
45
@property (readwrite, getter=number2, setter=setNumber2:) int count2;
46
@end
47
 
48
@implementation MySubClass
49
@synthesize count1;
50
@synthesize count2;
51
@end
52
 
53
int main (void)
54
{
55
  MySubClass *object = [[MySubClass alloc] init];
56
 
57
  object.count1 = 20;
58
  if (object.count1 != 20)
59
    abort ();
60
 
61
  object.count2 = 11;
62
  if (object.count2 != 11)
63
    abort ();
64
 
65
  return 0;
66
}

powered by: WebSVN 2.1.0

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