1 /* Check if the @defs() construct preserves the correct
2 layout of bitfields. */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-options "-Wpadded" } */
7 #include "../objc-obj-c++-shared/TestsuiteObject.m"
9 extern void abort(void);
10 extern int strcmp(const char *str1, const char *str2);
11 #define CHECK_IF(expr) if(!(expr)) abort()
13 enum Enum { one, two, three, four };
15 @interface Base: TestsuiteObject {
20 } /* { dg-warning "padding struct size to alignment boundary" } */
23 @interface Derived: Base {
27 } /* { dg-warning "padding struct size to alignment boundary" } */
30 /* Note that the semicolon after @defs(...) is optional. */
32 typedef struct { @defs(Base) } Base_t; /* { dg-warning "padding struct size to alignment boundary" } */
33 typedef struct { @defs(Derived); } Derived_t; /* { dg-warning "padding struct size to alignment boundary" } */
37 CHECK_IF(sizeof(Base_t) == sizeof(Base));
38 CHECK_IF(sizeof(Derived_t) == sizeof(Derived));
40 #ifdef __NEXT_RUNTIME__
41 CHECK_IF(!strcmp(@encode(Base), "{Base=#b2b3b4b5}"));
42 CHECK_IF(!strcmp(@encode(Derived), "{Derived=#b2b3b4b5b5b4b3}"));
44 CHECK_IF(!strcmp(@encode(Base_t), "{?=#b2b3b4b5}"));
45 CHECK_IF(!strcmp(@encode(Derived_t), "{?=#b2b3b4b5b5b4b3}"));
46 #endif /* __NEXT_RUNTIME__ */