Home | History | Annotate | Line # | Download | only in lint1
decl_struct_member.c revision 1.14
      1 /*	$NetBSD: decl_struct_member.c,v 1.14 2022/01/15 14:22:03 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 	/* expect+1: error: syntax error 'unnamed member' [249] */
     48 	char;
     49 };
     50 
     51 struct cover_notype_struct_declarators {
     52 	const a, b;
     53 };
     54 
     55 struct cover_notype_struct_declarator_bit_field {
     56 	const a:3, :0, b:4;
     57 	const:0;
     58 };
     59 
     60 /*
     61  * An array of bit-fields sounds like a strange idea since a bit-field member
     62  * is not addressable, while an array needs to be addressable.  Due to this
     63  * contradiction, this combination may have gone without mention in the C
     64  * standards.
     65  *
     66  * GCC 10.3.0 complains that the bit-field has invalid type.
     67  *
     68  * Clang 12.0.1 complains that the bit-field has non-integral type 'unsigned
     69  * int [8]'.
     70  */
     71 struct array_of_bit_fields {
     72 	/* expect+1: warning: illegal bit-field type 'array[8] of unsigned int' [35] */
     73 	unsigned int bits[8]: 1;
     74 };
     75 
     76 /*
     77  * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault.
     78  */
     79 struct {
     80 	/* expect+1: error: syntax error '0' [249] */
     81 	char a(_)0
     82 
     83 /*
     84  * Before cgram.y 1.328 from 2021-07-15, lint ran into an assertion failure
     85  * at the closing semicolon:
     86  *
     87  * assertion "t == NOTSPEC" failed in end_type at decl.c:774
     88  */
     89 };
     90 /* expect+1: cannot recover from previous errors */
     91