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: document why in ic_exp...
details: https://anonhg.NetBSD.org/src/rev/3f737c49b7ec
branches: trunk
changeset: 368368:3f737c49b7ec
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 07 18:11:29 2022 +0000
description:
tests/lint: document why in ic_expr, '&' does not need before_conversion
diffstat:
tests/usr.bin/xlint/lint1/msg_132.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diffs (30 lines):
diff -r 1851b09e2d1c -r 3f737c49b7ec tests/usr.bin/xlint/lint1/msg_132.c
--- a/tests/usr.bin/xlint/lint1/msg_132.c Thu Jul 07 13:27:02 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_132.c Thu Jul 07 18:11:29 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_132.c,v 1.23 2022/07/06 22:26:31 rillig Exp $ */
+/* $NetBSD: msg_132.c,v 1.24 2022/07/07 18:11:29 rillig Exp $ */
# 3 "msg_132.c"
// Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -329,3 +329,20 @@
/* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */
s8 = s64 % 1;
}
+
+void
+test_ic_bitand(void)
+{
+ /*
+ * ic_bitand assumes that integers are represented in 2's complement,
+ * and that the sign bit of signed integers behaves like a value bit.
+ * That way, the following expressions get their constraints computed
+ * correctly, regardless of whether ic_expr takes care of integer
+ * promotions or not. Compare ic_mod, which ignores signed types.
+ */
+
+ u8 = u8 & u16;
+
+ /* expect+1: warning: conversion from 'unsigned int' to 'unsigned char' may lose accuracy [132] */
+ u8 = u16 & u32;
+}
Home |
Main Index |
Thread Index |
Old Index