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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [property/] [synthesize-4.m] - Blame information for rev 704

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, 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 where the setter/getter are also
6
   declared by the user.  This is fine.  */
7
 
8
#include <objc/objc.h>
9
#include <objc/runtime.h>
10
#include <stdlib.h>
11
 
12
@interface MyRootClass
13
{
14
  Class isa;
15
}
16
+ (id) initialize;
17
+ (id) alloc;
18
- (id) init;
19
@end
20
 
21
@implementation MyRootClass
22
+ (id) initialize { return self; }
23
+ (id) alloc { return class_createInstance (self, 0); }
24
- (id) init { return self; }
25
@end
26
 
27
@protocol MyProtocol
28
@property int v1;
29
@end
30
 
31
@protocol MyProtocol2
32
@property int v2;
33
@end
34
 
35
@interface Test : MyRootClass <MyProtocol, MyProtocol2>
36
{
37
  int v1;
38
  int _v2;
39
}
40
- (int)v1;
41
- (void)setV1: (int)aNumber;
42
- (int)v2;
43
@end
44
 
45
@implementation Test
46
@synthesize v1;
47
@synthesize v2 = _v2;
48
@end
49
 
50
int main (void)
51
{
52
  Test *object = [[Test alloc] init];
53
 
54
  /* We use dot-syntax here as this is just a general test that
55
     user-declared setters/getters don't cause confusion.  */
56
  object.v1 = 400;
57
 
58
  if (object.v1 != 400)
59
    abort ();
60
 
61
  object.v2 = 31;
62
 
63
  if (object.v2 != 31)
64
    abort ();
65
 
66
  return 0;
67
}

powered by: WebSVN 2.1.0

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