lint: add test for message 35: illegal bit-field type
Bug: _Bool is not accepted as a bit-field, but it should be. Bug: lint aborts in a controlled manner with message "common/tyname.c, 190: tspec_name(0)" when it sees a declaration of a _Complex bit-field. (Not that a _Complex bit-field would make any sense.)
This commit is contained in:
parent
588c4b5800
commit
9a83ddef77
@ -1,7 +1,53 @@
|
||||
/* $NetBSD: msg_035.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
|
||||
/* $NetBSD: msg_035.c,v 1.2 2021/01/02 15:55:54 rillig Exp $ */
|
||||
# 3 "msg_035.c"
|
||||
|
||||
// Test for message: illegal bit-field type [35]
|
||||
|
||||
TODO: "Add example code that triggers the above message."
|
||||
TODO: "Add example code that almost triggers the above message."
|
||||
typedef struct {
|
||||
int dummy;
|
||||
} example_struct;
|
||||
|
||||
typedef union {
|
||||
int dummy;
|
||||
} example_union;
|
||||
|
||||
typedef enum {
|
||||
NO, YES
|
||||
} example_enum;
|
||||
|
||||
typedef void (example_function)(int, const char *);
|
||||
|
||||
/* Try all types from tspec_t. */
|
||||
struct example {
|
||||
signed signed_flag: 1;
|
||||
unsigned unsigned_flag: 1;
|
||||
_Bool boolean_flag: 1; // FIXME: allowed since C99 6.7.2.1p5
|
||||
char char_flag: 1;
|
||||
signed char signed_char_flag: 1;
|
||||
unsigned char unsigned_char_flag: 1;
|
||||
short short_flag: 1;
|
||||
unsigned short unsigned_short_flag: 1;
|
||||
int int_flag: 1;
|
||||
unsigned int unsigned_int_flag: 1;
|
||||
long long_flag: 1;
|
||||
unsigned long unsigned_long_flag: 1;
|
||||
long long long_long_flag: 1;
|
||||
unsigned long long unsigned_long_long_flag: 1;
|
||||
/* __int128_t omitted since it is not always defined */
|
||||
/* __uint128_t omitted since it is not always defined */
|
||||
float float_flag: 1;
|
||||
double double_flag: 1;
|
||||
long double long_double_flag: 1;
|
||||
void void_flag: 1;
|
||||
example_struct struct_flag: 1;
|
||||
example_union union_flag: 1;
|
||||
example_enum enum_flag: 1;
|
||||
void *pointer_flag: 1;
|
||||
unsigned int array_flag[4]: 1;
|
||||
example_function function_flag: 1;
|
||||
// FIXME: aborts: _Complex complex_flag: 1;
|
||||
_Complex complex_flag: 1;
|
||||
float _Complex float_complex_flag: 1;
|
||||
double _Complex double_complex_flag: 1;
|
||||
long double _Complex long_double_complex_flag: 1;
|
||||
};
|
||||
|
@ -1 +1,18 @@
|
||||
msg_035.c(6): syntax error ':' [249]
|
||||
msg_035.c(24): warning: illegal bit-field type [35]
|
||||
msg_035.c(32): warning: illegal bit-field type [35]
|
||||
msg_035.c(33): warning: illegal bit-field type [35]
|
||||
msg_035.c(34): warning: illegal bit-field type [35]
|
||||
msg_035.c(35): warning: illegal bit-field type [35]
|
||||
msg_035.c(38): warning: illegal bit-field type [35]
|
||||
msg_035.c(39): warning: illegal bit-field type [35]
|
||||
msg_035.c(40): warning: illegal bit-field type [35]
|
||||
msg_035.c(41): void type for void_flag [19]
|
||||
msg_035.c(41): zero size bit-field [37]
|
||||
msg_035.c(42): warning: illegal bit-field type [35]
|
||||
msg_035.c(43): warning: illegal bit-field type [35]
|
||||
msg_035.c(45): warning: illegal bit-field type [35]
|
||||
msg_035.c(46): warning: illegal bit-field type [35]
|
||||
msg_035.c(47): warning: illegal bit-field type [35]
|
||||
msg_035.c(49): warning: illegal bit-field type [35]
|
||||
msg_035.c(50): warning: illegal bit-field type [35]
|
||||
msg_035.c(51): warning: illegal bit-field type [35]
|
||||
|
Loading…
Reference in New Issue
Block a user