Module Name: src
Committed By: rillig
Date: Fri Apr 2 22:38:42 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_239.c msg_239.exp
Log Message:
tests/lint: add test for constant argument to '!'
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_239.c \
src/tests/usr.bin/xlint/lint1/msg_239.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_239.c
diff -u src/tests/usr.bin/xlint/lint1/msg_239.c:1.2 src/tests/usr.bin/xlint/lint1/msg_239.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_239.c:1.2 Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_239.c Fri Apr 2 22:38:42 2021
@@ -1,7 +1,18 @@
-/* $NetBSD: msg_239.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_239.c,v 1.3 2021/04/02 22:38:42 rillig Exp $ */
# 3 "msg_239.c"
// Test for message: constant argument to NOT [239]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -h */
+
+_Bool
+example(int n)
+{
+ _Bool b;
+
+ b = !0; /* expect: constant in conditional context, 239 */
+ b = !1; /* expect: constant in conditional context, 239 */
+ b = !(n > 1);
+
+ return b;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_239.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_239.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_239.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_239.exp:1.2 Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_239.exp Fri Apr 2 22:38:42 2021
@@ -1 +1,4 @@
-msg_239.c(6): error: syntax error ':' [249]
+msg_239.c(13): warning: constant in conditional context [161]
+msg_239.c(13): warning: constant argument to NOT [239]
+msg_239.c(14): warning: constant in conditional context [161]
+msg_239.c(14): warning: constant argument to NOT [239]