| 1 |
/* Check that the sizeof() operator works with ObjC classes and their aliases. */ |
| 2 |
/* Contributed by Ziemowit Laski <[email protected]>. */ |
| 3 |
/* { dg-options "" } */ |
| 4 |
/* { dg-do run } */ |
| 5 |
|
| 6 |
#include "../objc-obj-c++-shared/TestsuiteObject.m" |
| 7 |
#include <objc/objc.h> |
| 8 |
|
| 9 |
extern void abort(void); |
| 10 |
#define CHECK_IF(expr) if(!(expr)) abort(); |
| 11 |
|
| 12 |
@interface Foo: TestsuiteObject { |
| 13 |
int a, b; |
| 14 |
float c, d; |
| 15 |
} |
| 16 |
@end |
| 17 |
|
| 18 |
@implementation Foo |
| 19 |
@end |
| 20 |
|
| 21 |
typedef TestsuiteObject MyObject; |
| 22 |
typedef struct Foo Foo_type; |
| 23 |
|
| 24 |
@compatibility_alias AliasObject TestsuiteObject; |
| 25 |
|
| 26 |
int main(void) { |
| 27 |
CHECK_IF(sizeof(Foo) > sizeof(TestsuiteObject) && sizeof(TestsuiteObject) > 0); |
| 28 |
CHECK_IF(sizeof(Foo) == sizeof(Foo_type)); |
| 29 |
CHECK_IF(sizeof(TestsuiteObject) == sizeof(MyObject)); |
| 30 |
CHECK_IF(sizeof(TestsuiteObject) == sizeof(AliasObject)); |
| 31 |
return 0; |
| 32 |
} |
| 33 |
|