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 querying for octal integer c...
details: https://anonhg.NetBSD.org/src/rev/aba5bd54b8b4
branches: trunk
changeset: 374090:aba5bd54b8b4
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Mar 31 13:03:05 2023 +0000
description:
lint: allow querying for octal integer constants
diffstat:
tests/usr.bin/xlint/lint1/queries.c | 19 +++++++++++++++++--
usr.bin/xlint/lint1/err.c | 5 +++--
usr.bin/xlint/lint1/lex.c | 9 +++++++--
3 files changed, 27 insertions(+), 6 deletions(-)
diffs (96 lines):
diff -r 6cd6773c8f9c -r aba5bd54b8b4 tests/usr.bin/xlint/lint1/queries.c
--- a/tests/usr.bin/xlint/lint1/queries.c Fri Mar 31 07:34:26 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/queries.c Fri Mar 31 13:03:05 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: queries.c,v 1.10 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: queries.c,v 1.11 2023/03/31 13:03:05 rillig Exp $ */
# 3 "queries.c"
/*
@@ -15,7 +15,7 @@
* such as casts between arithmetic types.
*/
-/* lint1-extra-flags: -q 1,2,3,4,5,6,7 -X 351 */
+/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8 -X 351 */
typedef unsigned char u8_t;
typedef unsigned short u16_t;
@@ -294,6 +294,21 @@ Q7(void)
vstr = (vstr_t)vstr;
}
+/*
+ * Octal numbers were common in the 1970s, especially on 36-bit machines.
+ * 50 years later, they are still used in numeric file permissions.
+ */
+void
+Q8(void)
+{
+
+ u16 = 0;
+ u16 = 000000;
+ /* expect+1: octal number '0644' [Q8] */
+ u16 = 0644;
+ /* expect+1: octal number '0000644' [Q8] */
+ u16 = 0000644;
+}
/*
* Since queries do not affect the exit status, force a warning to make this
diff -r 6cd6773c8f9c -r aba5bd54b8b4 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Fri Mar 31 07:34:26 2023 +0000
+++ b/usr.bin/xlint/lint1/err.c Fri Mar 31 13:03:05 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.191 2023/03/28 20:04:52 rillig Exp $ */
+/* $NetBSD: err.c,v 1.192 2023/03/31 13:03:05 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.191 2023/03/28 20:04:52 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.192 2023/03/31 13:03:05 rillig Exp $");
#endif
#include <limits.h>
@@ -698,6 +698,7 @@ static const char *queries[] = {
"pointer addition has integer on the left-hand side", /* Q5 */
"no-op cast from '%s' to '%s'", /* Q6 */
"redundant cast from '%s' to '%s' before assignment", /* Q7 */
+ "octal number '%.*s'", /* Q8 */
};
bool any_query_enabled; /* for optimizing non-query scenarios */
diff -r 6cd6773c8f9c -r aba5bd54b8b4 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Fri Mar 31 07:34:26 2023 +0000
+++ b/usr.bin/xlint/lint1/lex.c Fri Mar 31 13:03:05 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.154 2023/02/19 12:00:15 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.155 2023/03/31 13:03:05 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.154 2023/02/19 12:00:15 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.155 2023/03/31 13:03:05 rillig Exp $");
#endif
#include <ctype.h>
@@ -514,6 +514,11 @@ lex_integer_constant(const char *yytext,
warned = true;
}
+ if (any_query_enabled && base == 8 && uq != 0) {
+ /* octal number '%.*s' */
+ query_message(8, (int)len, cp);
+ }
+
/*
* If the value is too big for the current type, we must choose
* another type.
Home |
Main Index |
Thread Index |
Old Index