lint: allow querying for octal integer constants
This commit is contained in:
parent
37b0b4baae
commit
ce2e717784
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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, size_t yyleng, int base)
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue