| 1 |
/* Contributed by Nicola Pero <[email protected]>, 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. */ |
| 6 |
|
| 7 |
#include <stdlib.h> |
| 8 |
#include <objc/objc.h> |
| 9 |
#include <objc/runtime.h> |
| 10 |
|
| 11 |
@interface MyRootClass |
| 12 |
{ |
| 13 |
Class isa; |
| 14 |
int a; |
| 15 |
id b; |
| 16 |
} |
| 17 |
+ (id) initialize; |
| 18 |
+ (id) alloc; |
| 19 |
- (id) init; |
| 20 |
- (int) count; |
| 21 |
- (void) setCount: (int)value; |
| 22 |
- (id) next; |
| 23 |
- (void) setNext: (id)value; |
| 24 |
@end |
| 25 |
|
| 26 |
@implementation MyRootClass |
| 27 |
+ (id) initialize { return self; } |
| 28 |
+ (id) alloc { return class_createInstance (self, 0); } |
| 29 |
- (id) init { return self; } |
| 30 |
- (int) count |
| 31 |
{ |
| 32 |
return a; |
| 33 |
} |
| 34 |
- (void) setCount: (int)value |
| 35 |
{ |
| 36 |
a = value; |
| 37 |
} |
| 38 |
- (id) next |
| 39 |
{ |
| 40 |
return b; |
| 41 |
} |
| 42 |
- (void) setNext: (id)value |
| 43 |
{ |
| 44 |
b = value; |
| 45 |
} |
| 46 |
@end |
| 47 |
|
| 48 |
int main (void) |
| 49 |
{ |
| 50 |
MyRootClass *object = [[MyRootClass alloc] init]; |
| 51 |
|
| 52 |
object.count = 40; |
| 53 |
if (object.count != 40) |
| 54 |
abort (); |
| 55 |
|
| 56 |
object.next = object; |
| 57 |
if (object.next != object) |
| 58 |
abort (); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
|