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: fix wrong warning about losing acc...
details: https://anonhg.NetBSD.org/src/rev/933494c44a68
branches: trunk
changeset: 954384:933494c44a68
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Apr 06 21:17:27 2021 +0000
description:
lint: fix wrong warning about losing accuracy when converting to _Bool
diffstat:
tests/usr.bin/xlint/lint1/msg_132.c | 9 +++++++--
tests/usr.bin/xlint/lint1/msg_132.exp | 1 -
usr.bin/xlint/lint1/tree.c | 7 +++++--
3 files changed, 12 insertions(+), 5 deletions(-)
diffs (61 lines):
diff -r 60bd86710a71 -r 933494c44a68 tests/usr.bin/xlint/lint1/msg_132.c
--- a/tests/usr.bin/xlint/lint1/msg_132.c Tue Apr 06 21:13:04 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.c Tue Apr 06 21:17:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_132.c,v 1.4 2021/04/06 21:10:37 rillig Exp $ */
+/* $NetBSD: msg_132.c,v 1.5 2021/04/06 21:17:28 rillig Exp $ */
# 3 "msg_132.c"
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -63,9 +63,14 @@
v64 = v32;
}
+/*
+ * Before tree.c 1.268 from 2021-04-06, lint wrongly warned that conversion to
+ * _Bool might lose accuracy. C99 6.3.1.2 defines a special conversion rule
+ * from scalar to _Bool though.
+ */
_Bool
to_bool(long a, long b)
{
/* seen in fp_lib.h, function wideRightShiftWithSticky */
- return a | b; /* expect: 132 *//*FIXME*/
+ return a | b;
}
diff -r 60bd86710a71 -r 933494c44a68 tests/usr.bin/xlint/lint1/msg_132.exp
--- a/tests/usr.bin/xlint/lint1/msg_132.exp Tue Apr 06 21:13:04 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.exp Tue Apr 06 21:17:27 2021 +0000
@@ -10,4 +10,3 @@
msg_132.c(54): warning: conversion from 'int' to 'short' may lose accuracy [132]
msg_132.c(55): warning: conversion from 'long long' to 'short' may lose accuracy [132]
msg_132.c(59): warning: conversion from 'long long' to 'int' may lose accuracy [132]
-msg_132.c(70): warning: conversion from 'long' to '_Bool' may lose accuracy [132]
diff -r 60bd86710a71 -r 933494c44a68 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Tue Apr 06 21:13:04 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c Tue Apr 06 21:17:27 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.267 2021/04/06 13:17:04 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.268 2021/04/06 21:17:27 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.267 2021/04/06 13:17:04 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.268 2021/04/06 21:17:27 rillig Exp $");
#endif
#include <float.h>
@@ -1948,6 +1948,9 @@
if (op == CVT)
return;
+ if (Sflag && nt == BOOL)
+ return; /* See C99 6.3.1.2 */
+
if (Pflag && portable_size_in_bits(nt) > portable_size_in_bits(ot) &&
is_uinteger(nt) != is_uinteger(ot)) {
if (aflag > 0 && pflag) {
Home |
Main Index |
Thread Index |
Old Index