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 lint: add test for 129, possibly d...



details:   https://anonhg.NetBSD.org/src/rev/370721f83bc4
branches:  trunk
changeset: 1018326:370721f83bc4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 30 22:38:54 2021 +0000

description:
lint: add test for 129, possibly demonstrating a bug in lint

diffstat:

 tests/usr.bin/xlint/lint1/msg_129.c   |  25 ++++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_129.exp |   2 +-
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r b7717d2ef19c -r 370721f83bc4 tests/usr.bin/xlint/lint1/msg_129.c
--- a/tests/usr.bin/xlint/lint1/msg_129.c       Sat Jan 30 22:07:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_129.c       Sat Jan 30 22:38:54 2021 +0000
@@ -1,7 +1,26 @@
-/*     $NetBSD: msg_129.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_129.c,v 1.2 2021/01/30 22:38:54 rillig Exp $       */
 # 3 "msg_129.c"
 
 // Test for message: expression has null effect [129]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -h */
+
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+
+/*
+ * XXX: The message 129 looks wrong in this case.  There are several comma
+ * operators, each of them has an assignment as operand, and an assignment
+ * has side effects.
+ *
+ * Nevertheless, when stepping through check_null_effect, the operator ','
+ * in line 17 says it has no side effect, which is strange.
+ */
+void
+uint8_buffer_write_uint32(uint8_t *c, uint32_t l)
+{
+       (*(c++) = (uint8_t)(l & 0xff),
+           *(c++) = (uint8_t)((l >> 8L) & 0xff),
+           *(c++) = (uint8_t)((l >> 16L) & 0xff),
+           *(c++) = (uint8_t)((l >> 24L) & 0xff));     /* expect: 129 */
+}
diff -r b7717d2ef19c -r 370721f83bc4 tests/usr.bin/xlint/lint1/msg_129.exp
--- a/tests/usr.bin/xlint/lint1/msg_129.exp     Sat Jan 30 22:07:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_129.exp     Sat Jan 30 22:38:54 2021 +0000
@@ -1,1 +1,1 @@
-msg_129.c(6): syntax error ':' [249]
+msg_129.c(25): warning: expression has null effect [129]



Home | Main Index | Thread Index | Old Index