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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [property/] [synthesize-7.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 with protocols of protocols.  */
6
 
7
#include <stdlib.h>
8
#include <objc/objc.h>
9
#include <objc/runtime.h>
10
 
11
@protocol ProtocolA
12
@property int countA;
13
@end
14
 
15
@protocol ProtocolB <ProtocolA>
16
@property int countB;
17
@end
18
 
19
@protocol ProtocolC <ProtocolB>
20
@property int countC;
21
@end
22
 
23
@protocol ProtocolD
24
@property int countD;
25
@end
26
 
27
@interface MyRootClass <ProtocolC>
28
{
29
  Class isa;
30
  int countA;
31
  int countB;
32
  int countC;
33
}
34
+ (id) initialize;
35
+ (id) alloc;
36
- (id) init;
37
@end
38
 
39
@implementation MyRootClass
40
+ (id) initialize { return self; }
41
+ (id) alloc { return class_createInstance (self, 0); }
42
- (id) init { return self; }
43
@synthesize countA;
44
@synthesize countB;
45
@synthesize countC;
46
@end
47
 
48
@interface MySubClass : MyRootClass <ProtocolD>
49
{
50
  int countD;
51
}
52
@end
53
 
54
@implementation MySubClass
55
@synthesize countD;
56
@end
57
 
58
int main (void)
59
{
60
  MySubClass *object = [[MySubClass alloc] init];
61
  int i;
62
 
63
  for (i = 0; i < 10; i++)
64
    {
65
      object.countA += i;
66
      object.countB += i + 1;
67
      object.countC += i + 2;
68
      object.countD += i + 3;
69
    }
70
 
71
  if (object.countA != 45)
72
    abort ();
73
 
74
  if (object.countB != 55)
75
    abort ();
76
 
77
  if (object.countC != 65)
78
    abort ();
79
 
80
  if (object.countD != 75)
81
    abort ();
82
 
83
  return 0;
84
}
85
 
86
 

powered by: WebSVN 2.1.0

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