Module Name: src
Committed By: rillig
Date: Thu Jul 7 18:11:30 UTC 2022
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_132.c
Log Message:
tests/lint: document why in ic_expr, '&' does not need before_conversion
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/msg_132.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/msg_132.c
diff -u src/tests/usr.bin/xlint/lint1/msg_132.c:1.23 src/tests/usr.bin/xlint/lint1/msg_132.c:1.24
--- src/tests/usr.bin/xlint/lint1/msg_132.c:1.23 Wed Jul 6 22:26:31 2022
+++ src/tests/usr.bin/xlint/lint1/msg_132.c Thu Jul 7 18:11:29 2022
@@ -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 @@ test_ic_mod(void)
/* 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;
+}