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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Basic test, auto-generated getter/setter based on named ivar  */
2
/* { dg-do run } */
3
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
 
5
#ifdef __cplusplus
6
extern "C" {
7
#endif
8
 
9
extern int printf (const char *fmt,...);
10
extern void abort (void);
11
 
12
#include 
13
#include 
14
 
15
#ifdef __cplusplus
16
}
17
#endif
18
 
19
@interface Bar
20
{
21
@public
22
  Class isa;
23
  int var;
24
}
25
+ (id) initialize;
26
+ (id) alloc ;
27
- (id) init;
28
 
29
@property int FooBar;
30
@end
31
 
32
@implementation Bar
33
 
34
+initialize { return self;}
35
+ (id) alloc { return class_createInstance (self, 0); }
36
 
37
- (id) init {return self;}
38
 
39
@synthesize FooBar = var;
40
@end
41
 
42
int main(int argc, char *argv[]) {
43
  int res;
44
  Bar *f = [[Bar alloc] init];
45
 
46
  /* First, establish that the property getter & setter have been synthesized
47
     and operate correctly.  */
48
  [f setFooBar:1234];
49
 
50
  if (f->var != 1234)
51
    { printf ("setFooBar did not set var correctly\n"); abort ();}
52
 
53
  res = [f FooBar];
54
 
55
  if (res != 1234 )
56
    { printf ("[f FooBar] = %d\n",  res); abort ();}
57
 
58
  /* Now check the short-cut object.property syntax.  */
59
  /* Read .... */
60
  res = f.FooBar;
61
  if (res != 1234 )
62
    { printf ("f.FooBar = %d\n",  res); abort ();}
63
 
64
  /* ... and write.  */
65
  f.FooBar = 0;
66
  /* printf ("seems OK\n",  res); */
67
  return f.FooBar;
68
}
69
 

powered by: WebSVN 2.1.0

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