Wed Apr 5 20:17:30 2023 UTC ()
lint: fix duplicate warning when parsing big float constants


(rillig)
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ldbl128.c
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ldbl96.c
diff -r1.155 -r1.156 src/usr.bin/xlint/lint1/lex.c

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ldbl128.c (expand / switch to context diff)
--- src/tests/usr.bin/xlint/lint1/platform_ldbl128.c 2023/04/05 20:13:01 1.4
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl128.c 2023/04/05 20:17:30 1.5
@@ -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 @@
  * 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] */

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_ldbl96.c (expand / switch to context diff)
--- src/tests/usr.bin/xlint/lint1/platform_ldbl96.c 2023/04/05 20:13:01 1.4
+++ src/tests/usr.bin/xlint/lint1/platform_ldbl96.c 2023/04/05 20:17:30 1.5
@@ -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 @@
  * 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] */

cvs diff -r1.155 -r1.156 src/usr.bin/xlint/lint1/lex.c (expand / switch to context diff)
--- src/usr.bin/xlint/lint1/lex.c 2023/03/31 13:03:05 1.155
+++ src/usr.bin/xlint/lint1/lex.c 2023/04/05 20:17:30 1.156
@@ -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 @@
 	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 */