Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: fix test for message 1...
details: https://anonhg.NetBSD.org/src/rev/f15c13695d07
branches: trunk
changeset: 365722:f15c13695d07
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Apr 20 22:50:56 2022 +0000
description:
tests/lint: fix test for message 132 to be platform-independent
On i386, the test failed because the warning in line 101 was not
generated. This was because size_t on i386 is unsigned int (see
arch/i386/targparam.h, SIZEOF_TSPEC). The result of the multiplication
had type unsigned int, and message 132 does not trigger for a conversion
from unsigned int to signed int because both types have the same size
(see check_integer_conversion, portable_size_in_bits).
Change the involved type from size_t (which the original code used) to
unsigned long long (which is uint64_t on all platforms supported by
lint), so that the warning is generated on all platforms in the same
way.
diffstat:
tests/usr.bin/xlint/lint1/msg_132.c | 6 +++---
tests/usr.bin/xlint/lint1/msg_132.exp | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diffs (27 lines):
diff -r 19cdbdcbb341 -r f15c13695d07 tests/usr.bin/xlint/lint1/msg_132.c
--- a/tests/usr.bin/xlint/lint1/msg_132.c Wed Apr 20 22:08:10 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.c Wed Apr 20 22:50:56 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_132.c,v 1.7 2022/04/19 22:40:13 rillig Exp $ */
+/* $NetBSD: msg_132.c,v 1.8 2022/04/20 22:50:56 rillig Exp $ */
# 3 "msg_132.c"
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -97,6 +97,6 @@
* that the conversion will always succeed.
*/
const int not_a_constant = 8;
- /* expect+1: warning: conversion from 'unsigned long' to 'int' may lose accuracy [132] */
- return sizeof(double) + not_a_constant * sizeof(char *);
+ /* expect+1: warning: conversion from 'unsigned long long' to 'int' may lose accuracy [132] */
+ return not_a_constant * 8ULL;
}
diff -r 19cdbdcbb341 -r f15c13695d07 tests/usr.bin/xlint/lint1/msg_132.exp
--- a/tests/usr.bin/xlint/lint1/msg_132.exp Wed Apr 20 22:08:10 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.exp Wed Apr 20 22:50:56 2022 +0000
@@ -12,4 +12,4 @@
msg_132.c(59): warning: conversion from 'long long' to 'int' may lose accuracy [132]
msg_132.c(85): error: operands of '+' have incompatible types (pointer != double) [107]
msg_132.c(85): warning: function 'cover_build_plus_minus' expects to return value [214]
-msg_132.c(101): warning: conversion from 'unsigned long' to 'int' may lose accuracy [132]
+msg_132.c(101): warning: conversion from 'unsigned long long' to 'int' may lose accuracy [132]
Home |
Main Index |
Thread Index |
Old Index