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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 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
extern int printf (char *fmt,...) ;
6
extern void abort (void);
7
 
8
#include <objc/objc.h>
9
#include <objc/runtime.h>
10
 
11
@interface Bar
12
{
13
@public
14
  Class isa;
15
  int var;
16
}
17
+ (id) initialize;
18
+ (id) alloc ;
19
- (id) init;
20
 
21
@property int FooBar;
22
@end
23
 
24
@implementation Bar
25
 
26
+initialize { return self;}
27
+ (id) alloc { return class_createInstance (self, 0); }
28
 
29
- (id) init {return self;}
30
 
31
@synthesize FooBar = var;
32
@end
33
 
34
int main(int argc, char *argv[]) {
35
  int res;
36
  Bar *f = [[Bar alloc] init];
37
 
38
  /* First, establish that the property getter & setter have been synthesized
39
     and operate correctly.  */
40
  [f setFooBar:1234];
41
 
42
  if (f->var != 1234)
43
    { printf ("setFooBar did not set var correctly\n"); abort ();}
44
 
45
  res = [f FooBar];
46
 
47
  if (res != 1234 )
48
    { printf ("[f FooBar] = %d\n",  res); abort ();}
49
 
50
  /* Now check the short-cut object.property syntax.  */
51
  /* Read .... */
52
  res = f.FooBar;
53
  if (res != 1234 )
54
    { printf ("f.FooBar = %d\n",  res); abort ();}
55
 
56
  /* ... and write.  */
57
  f.FooBar = 0;
58
  /* printf ("seems OK\n",  res); */
59
  return f.FooBar;
60
}
61
 

powered by: WebSVN 2.1.0

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