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