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: only warn once about integer const...
details: https://anonhg.NetBSD.org/src/rev/e507d53db7f2
branches: trunk
changeset: 953201:e507d53db7f2
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Mar 01 00:51:01 2021 +0000
description:
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal,
but only on 32-bit platforms. On 64-bit platforms, there was only a
single warning since the integer constant was converted to type
__uint128_t, and this prevented the second warning. On 32-bit targets,
there is no __uint128_t though.
Fixes part of PR bin/55976.
diffstat:
usr.bin/xlint/lint1/lex.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diffs (92 lines):
diff -r de381abb7997 -r e507d53db7f2 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Feb 28 23:12:37 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Mon Mar 01 00:51:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.10 2021/02/28 18:51:51 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.11 2021/03/01 00:51:01 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: lex.c,v 1.10 2021/02/28 18:51:51 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.11 2021/03/01 00:51:01 rillig Exp $");
#endif
#include <ctype.h>
@@ -478,6 +478,7 @@
char c, *eptr;
tspec_t typ;
bool ansiu;
+ bool warned = false;
#ifdef TARG_INT128_MAX
__uint128_t uq = 0;
static tspec_t contypes[2][4] = {
@@ -531,9 +532,11 @@
uq = strtouq(cp, &eptr, base);
lint_assert(eptr == cp + len);
- if (errno != 0)
+ if (errno != 0) {
/* integer constant out of range */
warning(252);
+ warned = true;
+ }
/*
* If the value is too big for the current type, we must choose
@@ -550,7 +553,7 @@
typ = LONG;
} else {
typ = ULONG;
- if (uq > TARG_ULONG_MAX) {
+ if (uq > TARG_ULONG_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
@@ -570,7 +573,7 @@
case UINT:
if (uq > TARG_UINT_MAX) {
typ = ULONG;
- if (uq > TARG_ULONG_MAX) {
+ if (uq > TARG_ULONG_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
@@ -581,14 +584,14 @@
typ = ULONG;
if (!sflag)
ansiu = true;
- if (uq > TARG_ULONG_MAX) {
+ if (uq > TARG_ULONG_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
}
break;
case ULONG:
- if (uq > TARG_ULONG_MAX) {
+ if (uq > TARG_ULONG_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
@@ -601,7 +604,7 @@
}
break;
case UQUAD:
- if (uq > TARG_UQUAD_MAX) {
+ if (uq > TARG_UQUAD_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
@@ -618,7 +621,7 @@
break;
case UINT128:
#ifdef TARG_INT128_MAX
- if (uq > TARG_UINT128_MAX) {
+ if (uq > TARG_UINT128_MAX && !warned) {
/* integer constant out of range */
warning(252);
}
Home |
Main Index |
Thread Index |
Old Index