| 1 |
/* Test out static (non-heap) allocations of ObjC class instances. |
| 2 |
These should elicit errors. */ |
| 3 |
/* Developed by Ziemowit Laski <[email protected]>. */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
|
| 6 |
@interface Object { |
| 7 |
struct objc_class *isa; |
| 8 |
} |
| 9 |
@end |
| 10 |
|
| 11 |
@compatibility_alias MyObject Object; |
| 12 |
|
| 13 |
@interface Foo: Object { |
| 14 |
int a; |
| 15 |
Object *b; |
| 16 |
Object c; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ |
| 17 |
} |
| 18 |
@end |
| 19 |
|
| 20 |
@compatibility_alias MyFoo Foo; |
| 21 |
|
| 22 |
typedef Foo FooAlias1; |
| 23 |
typedef FooAlias1 FooAlias2; |
| 24 |
typedef Object ObjectAlias1; |
| 25 |
typedef struct Object ObjectAlias2; |
| 26 |
Object staticObject1; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ |
| 27 |
struct Object staticObject2; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ |
| 28 |
static ObjectAlias1 staticObject3; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ |
| 29 |
FooAlias1 staticFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ |
| 30 |
extern FooAlias2 externFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ |
| 31 |
static Foo staticFoo2; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ |
| 32 |
MyObject staticMyObject1; /* { dg-error "statically allocated instance of Objective-C class .Object." } */ |
| 33 |
MyFoo staticMyFoo1; /* { dg-error "statically allocated instance of Objective-C class .Foo." } */ |