1 /* Check if the @defs() construct preserves the correct
2 layout of bitfields. */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-options "-lobjc -Wpadded" } */
7 #include <objc/Object.h>
12 #define CHECK_IF(expr) if(!(expr)) abort()
14 enum Enum { one, two, three, four };
16 @interface Base: Object {
21 } /* { dg-warning "padding struct size to alignment boundary" } */
24 @interface Derived: Base {
31 /* Note that the semicolon after @defs(...) is optional. */
33 typedef struct { @defs(Base) } Base_t; /* { dg-warning "padding struct size to alignment boundary" } */
34 typedef struct { @defs(Derived); } Derived_t;
38 CHECK_IF(sizeof(Base_t) == sizeof(Base));
39 CHECK_IF(sizeof(Derived_t) == sizeof(Derived));
41 #ifdef __NEXT_RUNTIME__
42 CHECK_IF(!strcmp(@encode(Base), "{Base=#b2b3b4b5}"));
43 CHECK_IF(!strcmp(@encode(Derived), "{Derived=#b2b3b4b5b5b4b3}"));
45 CHECK_IF(!strcmp(@encode(Base_t), "{?=#b2b3b4b5}"));
46 CHECK_IF(!strcmp(@encode(Derived_t), "{?=#b2b3b4b5b5b4b3}"));
47 #endif /* __NEXT_RUNTIME__ */
52 /* { dg-bogus "included from <built-in>" "PR23610" { xfail lp64 } 0 } */
53 /* { dg-bogus "padding struct to align" "PR23610" { xfail lp64 } 0 } */
55 /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 28 } */
56 /* { dg-bogus "padding struct size" "PR23610" { xfail lp64 } 34 } */