Module Name: src
Committed By: rillig
Date: Sat Jan 30 22:38:54 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_129.c msg_129.exp
Log Message:
lint: add test for 129, possibly demonstrating a bug in lint
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_129.c \
src/tests/usr.bin/xlint/lint1/msg_129.exp
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_129.c
diff -u src/tests/usr.bin/xlint/lint1/msg_129.c:1.1 src/tests/usr.bin/xlint/lint1/msg_129.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_129.c:1.1 Sat Jan 2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_129.c Sat Jan 30 22:38:54 2021
@@ -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 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_129.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_129.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_129.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_129.exp:1.1 Sat Jan 2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_129.exp Sat Jan 30 22:38:54 2021
@@ -1 +1 @@
-msg_129.c(6): syntax error ':' [249]
+msg_129.c(25): warning: expression has null effect [129]