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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [property/] [dotsyntax-2.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 the 'dot syntax' without a declarated property.  This tests the case where
6
   only the setter (or only the getter) exists.  */
7
 
8
#include <stdlib.h>
9
#include <objc/objc.h>
10
#include <objc/runtime.h>
11
 
12
@interface MyRootClass
13
{
14
  Class isa;
15
  int a;
16
  id b;
17
}
18
+ (id) initialize;
19
+ (id) alloc;
20
- (id) init;
21
- (int) a;
22
- (void) setCount: (int)value;
23
- (id) b;
24
- (void) setNext: (id)value;
25
@end
26
 
27
@implementation MyRootClass
28
+ (id) initialize { return self; }
29
+ (id) alloc { return class_createInstance (self, 0); }
30
- (id) init { return self; }
31
- (int) a
32
{
33
  return a;
34
}
35
- (void) setCount: (int)value
36
{
37
  a = value;
38
}
39
- (id) b
40
{
41
  return b;
42
}
43
- (void) setNext: (id)value
44
{
45
  b = value;
46
}
47
@end
48
 
49
int main (void)
50
{
51
  MyRootClass *object = [[MyRootClass alloc] init];
52
 
53
  /* This should work because -setCount: exists (even if -count does
54
     not).  */
55
  object.count = 40;
56
 
57
  /* This should work because -a exists (even if -setA: does not).  */
58
  if (object.a != 40)
59
    abort ();
60
 
61
  /* This should work because -setNext: exists (even if -next does
62
     not).  */
63
  object.next = object;
64
 
65
  /* This should work because -b exists (even if -setB: does not).  */
66
  if (object.b != object)
67
    abort ();
68
 
69
  return 0;
70
}
71
 
72
 

powered by: WebSVN 2.1.0

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