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