Module Name: src
Committed By: rillig
Date: Wed Apr 5 20:17:30 UTC 2023
Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ldbl128.c platform_ldbl96.c
src/usr.bin/xlint/lint1: lex.c
Log Message:
lint: fix duplicate warning when parsing big float constants
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ldbl128.c \
src/tests/usr.bin/xlint/lint1/platform_ldbl96.c
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/xlint/lint1/lex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/platform_ldbl128.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.4 src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.5
--- src/tests/usr.bin/xlint/lint1/platform_ldbl128.c:1.4 Wed Apr 5 20:13:01 2023
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl128.c Wed Apr 5 20:17:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_ldbl128.c,v 1.4 2023/04/05 20:13:01 rillig Exp $ */
+/* $NetBSD: platform_ldbl128.c,v 1.5 2023/04/05 20:17:30 rillig Exp $ */
# 3 "platform_ldbl128.c"
/*
@@ -19,8 +19,6 @@ typedef int bytes_per_long_double[sizeof
* 1.189e4932. This is in the same range as for 96-bit 'long double', as the
* exponent range is the same.
*/
-/* FIXME: remove the duplicate warning. */
-/* expect+2: warning: floating-point constant out of range [248] */
/* expect+1: warning: floating-point constant out of range [248] */
double larger_than_ldbl = 1e4933;
/* expect+1: warning: floating-point constant out of range [248] */
Index: src/tests/usr.bin/xlint/lint1/platform_ldbl96.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.4 src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.5
--- src/tests/usr.bin/xlint/lint1/platform_ldbl96.c:1.4 Wed Apr 5 20:13:01 2023
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl96.c Wed Apr 5 20:17:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_ldbl96.c,v 1.4 2023/04/05 20:13:01 rillig Exp $ */
+/* $NetBSD: platform_ldbl96.c,v 1.5 2023/04/05 20:17:30 rillig Exp $ */
# 3 "platform_ldbl96.c"
/*
@@ -18,8 +18,6 @@ typedef int bytes_per_long_double[sizeof
* This means the maximum representable value is 1.1111111(bin) * 2^16383,
* which is about 1.189e4932.
*/
-/* FIXME: Remove the duplicate warning. */
-/* expect+2: warning: floating-point constant out of range [248] */
/* expect+1: warning: floating-point constant out of range [248] */
double larger_than_ldbl = 1e4933;
/* expect+1: warning: floating-point constant out of range [248] */
Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.155 src/usr.bin/xlint/lint1/lex.c:1.156
--- src/usr.bin/xlint/lint1/lex.c:1.155 Fri Mar 31 13:03:05 2023
+++ src/usr.bin/xlint/lint1/lex.c Wed Apr 5 20:17:30 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.155 2023/03/31 13:03:05 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.156 2023/04/05 20:17:30 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.155 2023/03/31 13:03:05 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.156 2023/04/05 20:17:30 rillig Exp $");
#endif
#include <ctype.h>
@@ -649,11 +649,10 @@ lex_floating_constant(const char *yytext
char *eptr;
long double ld = strtold(cp, &eptr);
lint_assert(eptr == cp + len);
- if (errno != 0)
+ if (errno != 0) {
/* floating-point constant out of range */
warning(248);
-
- if (typ == FLOAT) {
+ } else if (typ == FLOAT) {
ld = (float)ld;
if (isfinite(ld) == 0) {
/* floating-point constant out of range */