1 /* $NetBSD: decl_struct_member.c,v 1.13 2021/12/22 14:49:11 rillig Exp $ */ 2 # 3 "decl_struct_member.c" 3 4 struct multi_attributes { 5 __attribute__((deprecated)) 6 __attribute__((deprecated)) 7 __attribute__((deprecated)) 8 int deprecated; 9 }; 10 11 struct cover_begin_type_specifier_qualifier_list { 12 int m1; 13 __attribute__((deprecated)) int m2; 14 const int m3; 15 int const m4; 16 int const long m5; 17 int __attribute__((deprecated)) m6; 18 }; 19 20 typedef int number; 21 22 struct cover_begin_type_typespec { 23 int m1; 24 number m2; 25 }; 26 27 struct cover_begin_type_qualifier_list { 28 const m1; 29 const volatile m2; 30 }; 31 32 /* cover struct_or_union_specifier: struct_or_union error */ 33 /* expect+1: error: syntax error 'goto' [249] */ 34 struct goto { 35 /* expect+1: error: illegal type combination [4] */ 36 int member; 37 /* expect+1: error: syntax error '}' [249] */ 38 }; 39 /* expect-1: warning: empty declaration [0] */ 40 41 /* 42 * Before cgram.y 1.228 from 2021-06-19, lint ran into an assertion failure: 43 * 44 * "is_struct_or_union(dcs->d_type->t_tspec)" at cgram.y:846 45 */ 46 struct { 47 char; /* expect: syntax error 'unnamed member' */ 48 }; 49 50 struct cover_notype_struct_declarators { 51 const a, b; 52 }; 53 54 struct cover_notype_struct_declarator_bit_field { 55 const a:3, :0, b:4; 56 const:0; 57 }; 58 59 /* 60 * An array of bit-fields sounds like a strange idea since a bit-field member 61 * is not addressable, while an array needs to be addressable. Due to this 62 * contradiction, this combination may have gone without mention in the C 63 * standards. 64 * 65 * GCC 10.3.0 complains that the bit-field has invalid type. 66 * 67 * Clang 12.0.1 complains that the bit-field has non-integral type 'unsigned 68 * int [8]'. 69 */ 70 struct array_of_bit_fields { 71 /* expect+1: warning: illegal bit-field type 'array[8] of unsigned int' [35] */ 72 unsigned int bits[8]: 1; 73 }; 74 75 /* 76 * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault. 77 */ 78 struct { 79 char a(_)0 /* expect: syntax error '0' */ 80 81 /* 82 * Before cgram.y 1.328 from 2021-07-15, lint ran into an assertion failure 83 * at the closing semicolon: 84 * 85 * assertion "t == NOTSPEC" failed in end_type at decl.c:774 86 */ 87 }; 88 /* expect+1: cannot recover from previous errors */ 89