| 1 |
/* Check if bitfield ivars are correctly @encode'd when |
| 2 |
the NeXT runtime is used. */ |
| 3 |
/* Contributed by Ziemowit Laski <[email protected]>. */ |
| 4 |
/* { dg-do run { target *-*-darwin* } } */ |
| 5 |
/* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */ |
| 6 |
/* { dg-options "-fsigned-char" } */ |
| 7 |
// { dg-additional-options "-Wno-objc-root-class" } |
| 8 |
|
| 9 |
typedef struct objc_object { struct objc_class *class_pointer; } *id; |
| 10 |
|
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
#define CHECK_IF(expr) if(!(expr)) abort(); |
| 15 |
|
| 16 |
@interface Base |
| 17 |
{ |
| 18 |
struct objc_class *isa; |
| 19 |
int full; |
| 20 |
int full2: 32; |
| 21 |
int _refs: 8; |
| 22 |
int field2: 3; |
| 23 |
unsigned f3: 8; |
| 24 |
short cc; |
| 25 |
unsigned g: 16; |
| 26 |
int r2: 8; |
| 27 |
int r3: 8; |
| 28 |
int r4: 2; |
| 29 |
int r5: 8; |
| 30 |
char c; |
| 31 |
} |
| 32 |
@end |
| 33 |
|
| 34 |
@interface Derived: Base |
| 35 |
{ |
| 36 |
char d; |
| 37 |
int _field3: 6; |
| 38 |
} |
| 39 |
@end |
| 40 |
|
| 41 |
@implementation Base |
| 42 |
@end |
| 43 |
|
| 44 |
@implementation Derived |
| 45 |
@end |
| 46 |
|
| 47 |
int main(void) { |
| 48 |
const char *s1r = "{Base=#ib32b8b3b8sb16b8b8b2b8c}"; |
| 49 |
const char *s1 = @encode(Base); |
| 50 |
const char *s2r = "{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}"; |
| 51 |
const char *s2 = @encode(Derived); |
| 52 |
|
| 53 |
CHECK_IF(!strcmp(s1r, s1)); |
| 54 |
CHECK_IF(!strcmp(s2r, s2)); |
| 55 |
|
| 56 |
return 0; |
| 57 |
} |