lint: fix wording of warning about bit-field initializer

This commit is contained in:
rillig 2024-03-29 07:35:45 +00:00
parent fa5625f426
commit 55398a9a51
3 changed files with 10 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: msg_186.c,v 1.6 2023/03/28 14:44:35 rillig Exp $ */
/* $NetBSD: msg_186.c,v 1.7 2024/03/29 07:35:45 rillig Exp $ */
# 3 "msg_186.c"
/* Test for message: bit-field initialization is illegal in traditional C [186] */
/* Test for message: bit-field initializer must be an integer in traditional C [186] */
/* lint1-flags: -tw -X 351 */
@ -13,8 +13,7 @@ struct bit_field {
struct bit_field bit_field = {
1,
/* expect+1: warning: bit-field initialization is illegal in traditional C [186] */
/* expect+1: warning: bit-field initializer must be an integer in traditional C [186] */
3.0,
2
};
/* XXX: The message is misleading. Initialization using integers is ok. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.235 2024/03/28 21:04:48 rillig Exp $ */
/* $NetBSD: err.c,v 1.236 2024/03/29 07:35:45 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
__RCSID("$NetBSD: err.c,v 1.235 2024/03/28 21:04:48 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.236 2024/03/29 07:35:45 rillig Exp $");
#endif
#include <limits.h>
@ -241,7 +241,7 @@ static const char *const msgs[] = {
"illegal combination of %s '%s' and %s '%s'", // 183
"illegal combination of '%s' and '%s'", // 184
"cannot initialize '%s' from '%s'", // 185
"bit-field initialization is illegal in traditional C", // 186
"bit-field initializer must be an integer in traditional C", // 186
"string literal too long (%ju) for target array (%ju)", // 187
"no automatic aggregate initialization in traditional C", // 188
"", /* no longer used */ // 189

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.264 2024/03/27 19:28:20 rillig Exp $ */
/* $NetBSD: init.c,v 1.265 2024/03/29 07:35:45 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
__RCSID("$NetBSD: init.c,v 1.264 2024/03/27 19:28:20 rillig Exp $");
__RCSID("$NetBSD: init.c,v 1.265 2024/03/29 07:35:45 rillig Exp $");
#endif
#include <stdlib.h>
@ -223,10 +223,9 @@ check_bit_field_init(const tnode_t *ln, tspec_t lt, tspec_t rt)
if (!allow_c90 &&
is_integer(lt) &&
ln->tn_type->t_bitfield &&
!is_integer(rt)) {
/* bit-field initialization is illegal in traditional C */
!is_integer(rt))
/* bit-field initializer must be an integer in ... */
warning(186);
}
}
static void