Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: allow large integer types for bit-...
details: https://anonhg.NetBSD.org/src/rev/172a216234dd
branches: trunk
changeset: 1021022:172a216234dd
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 02 22:07:49 2021 +0000
description:
lint: allow large integer types for bit-fields in GCC mode
These types are explicitly allowed by GCC.
I'm not sure which of the flags -g and -p should be stronger. That is,
if both -g and -p are given, should 'unsigned char' be allowed as a
bit-field type since -g would allow it, or should it be warned about
since -p warns about it? For now, continue to warn about these.
diffstat:
tests/usr.bin/xlint/lint1/gcc_bit_field_types.c | 12 ++++++------
tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp | 4 ----
usr.bin/xlint/lint1/decl.c | 6 +++---
3 files changed, 9 insertions(+), 13 deletions(-)
diffs (60 lines):
diff -r 53e76d67b9f5 -r 172a216234dd tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
--- a/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c Sun May 02 21:48:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c Sun May 02 22:07:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_bit_field_types.c,v 1.2 2021/05/02 21:47:28 rillig Exp $ */
+/* $NetBSD: gcc_bit_field_types.c,v 1.3 2021/05/02 22:07:49 rillig Exp $ */
# 3 "gcc_bit_field_types.c"
/*
@@ -13,9 +13,9 @@
struct example {
int int_flag: 1;
unsigned int unsigned_int_flag: 1;
- long long_flag: 1; /* expect: 35 *//*FIXME*/
- unsigned long unsigned_long_flag: 1; /* expect: 35 *//*FIXME*/
- long long long_long_flag: 1; /* expect: 35 *//*FIXME*/
- unsigned long long unsigned_long_long_flag: 1; /* expect: 35 *//*FIXME*/
- double double_flag: 1; /* expect: 35 */
+ long long_flag: 1;
+ unsigned long unsigned_long_flag: 1;
+ long long long_long_flag: 1;
+ unsigned long long unsigned_long_long_flag: 1;
+ double double_flag: 1; /* expect: illegal bit-field type 'double' */
};
diff -r 53e76d67b9f5 -r 172a216234dd tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp
--- a/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp Sun May 02 21:48:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp Sun May 02 22:07:49 2021 +0000
@@ -1,5 +1,1 @@
-gcc_bit_field_types.c(16): warning: illegal bit-field type 'long' [35]
-gcc_bit_field_types.c(17): warning: illegal bit-field type 'unsigned long' [35]
-gcc_bit_field_types.c(18): warning: illegal bit-field type 'long long' [35]
-gcc_bit_field_types.c(19): warning: illegal bit-field type 'unsigned long long' [35]
gcc_bit_field_types.c(20): warning: illegal bit-field type 'double' [35]
diff -r 53e76d67b9f5 -r 172a216234dd usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun May 02 21:48:53 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun May 02 22:07:49 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.179 2021/05/02 21:48:53 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.180 2021/05/02 22:07:49 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.179 2021/05/02 21:48:53 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.180 2021/05/02 22:07:49 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1121,7 +1121,7 @@
* regardless of BITFIELDTYPE. Integer types not dealt with
* above are okay only if BITFIELDTYPE is in effect.
*/
- if (!bitfieldtype_ok || !is_integer(t)) {
+ if (!(bitfieldtype_ok || gflag) || !is_integer(t)) {
/* illegal bit-field type '%s' */
warning(35, type_name(tp));
int sz = tp->t_flen;
Home |
Main Index |
Thread Index |
Old Index