d_packed_structs.c revision 1.5
1/* $NetBSD: d_packed_structs.c,v 1.5 2023/08/01 19:52:15 rillig Exp $ */ 2# 3 "d_packed_structs.c" 3 4/* packed tests */ 5 6/* lint1-extra-flags: -X 351 */ 7 8struct in_addr { 9 int x; 10}; 11struct ip_timestamp { 12 char ipt_code; 13 char ipt_len; 14 char ipt_ptr; 15 unsigned int 16 ipt_flg: 4, 17 ipt_oflw: 4; 18 union ipt_timestamp { 19 int ipt_time[1]; 20 struct ipt_ta { 21 struct in_addr ipt_addr; 22 int ipt_time; 23 } ipt_ta[1]__packed; 24 } ipt_timestamp__packed; 25} __packed; 26 27typedef struct __packed { 28 int x; 29} t; 30 31struct x { 32 char c; 33 long l; 34} __packed; 35 36struct y { 37 char c; 38 long l; 39}; 40 41int a[sizeof(struct y) - sizeof(struct x) - 1]; 42 43/* expect+1: error: negative array dimension (-9) [20] */ 44typedef int sizeof_x[-(int)sizeof(struct x)]; 45/* expect+1: error: negative array dimension (-16) [20] */ 46typedef int sizeof_y[-(int)sizeof(struct y)]; 47