1f08c3bdfSopenharmony_ci#define alignof(X) __alignof__(X) 2f08c3bdfSopenharmony_ci#define __packed __attribute__((packed)) 3f08c3bdfSopenharmony_ci 4f08c3bdfSopenharmony_cistruct sa { 5f08c3bdfSopenharmony_ci int a:7; 6f08c3bdfSopenharmony_ci int c:10; 7f08c3bdfSopenharmony_ci int b:2; 8f08c3bdfSopenharmony_ci} __packed; 9f08c3bdfSopenharmony_ci_Static_assert(alignof(struct sa) == 1, "alignof(struct sa)"); 10f08c3bdfSopenharmony_ci_Static_assert( sizeof(struct sa) == 3, "sizeof(struct sa)"); 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_cistatic int get_size(void) 14f08c3bdfSopenharmony_ci{ 15f08c3bdfSopenharmony_ci return sizeof(struct sa); 16f08c3bdfSopenharmony_ci} 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic void chk_align(struct sa sa, struct sa *p) 19f08c3bdfSopenharmony_ci{ 20f08c3bdfSopenharmony_ci _Static_assert(alignof(sa) == 1, "alignof(sa)"); 21f08c3bdfSopenharmony_ci _Static_assert(alignof(*p) == 1, "alignof(*p)"); 22f08c3bdfSopenharmony_ci} 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_cistatic int fp0(struct sa *sa) 25f08c3bdfSopenharmony_ci{ 26f08c3bdfSopenharmony_ci return sa->c; 27f08c3bdfSopenharmony_ci} 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_cistatic int fpx(struct sa *sa, int idx) 30f08c3bdfSopenharmony_ci{ 31f08c3bdfSopenharmony_ci return sa[idx].c; 32f08c3bdfSopenharmony_ci} 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_cistatic int fglobal(void) 35f08c3bdfSopenharmony_ci{ 36f08c3bdfSopenharmony_ci extern struct sa g; 37f08c3bdfSopenharmony_ci return g.c; 38f08c3bdfSopenharmony_ci} 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_cistatic struct sa l; 41f08c3bdfSopenharmony_cistatic int flocal(void) 42f08c3bdfSopenharmony_ci{ 43f08c3bdfSopenharmony_ci return l.c; 44f08c3bdfSopenharmony_ci} 45f08c3bdfSopenharmony_ci 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ciint main(void) 48f08c3bdfSopenharmony_ci{ 49f08c3bdfSopenharmony_ci extern void fun(struct sa *); 50f08c3bdfSopenharmony_ci struct sa sa = { 0 }; 51f08c3bdfSopenharmony_ci 52f08c3bdfSopenharmony_ci fun(&sa); 53f08c3bdfSopenharmony_ci return 0; 54f08c3bdfSopenharmony_ci} 55f08c3bdfSopenharmony_ci 56f08c3bdfSopenharmony_ci/* 57f08c3bdfSopenharmony_ci * check-name: packed-bitfield0 58f08c3bdfSopenharmony_ci */ 59