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

Subversion Repositories openrisc

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

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 @synthesize for a @property which is not declared directly in
6
   the @interface, but in a @protocol that the @interface conforms
7
   to.  */
8
 
9
#include 
10
#include 
11
#include 
12
 
13
@interface MyRootClass
14
{
15
  Class isa;
16
}
17
+ (id) initialize;
18
+ (id) alloc;
19
- (id) init;
20
@end
21
 
22
@implementation MyRootClass
23
+ (id) initialize { return self; }
24
+ (id) alloc { return class_createInstance (self, 0); }
25
- (id) init { return self; }
26
@end
27
 
28
@protocol MyProtocol
29
@property int v1;
30
@end
31
 
32
@protocol MyProtocol2
33
@property int v2;
34
@end
35
 
36
@interface Test : MyRootClass 
37
{
38
  int v1;
39
  int _v2;
40
}
41
@end
42
 
43
@implementation Test
44
@synthesize v1;
45
@synthesize v2 = _v2;
46
@end
47
 
48
int main (void)
49
{
50
  Test *object = [[Test alloc] init];
51
 
52
  /* Check that the synthesized methods exist and work.  Do not invoke
53
     them via property syntax - that is another test.  Here we just
54
     want to test the synthesis of the methods.  */
55
  [object setV1: 400];
56
 
57
  if ([object v1] != 400)
58
    abort ();
59
 
60
  [object setV2: 31];
61
 
62
  if ([object v2] != 31)
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.