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: add test for constant ...



details:   https://anonhg.NetBSD.org/src/rev/c4ae5981ca9f
branches:  trunk
changeset: 960927:c4ae5981ca9f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 02 22:38:42 2021 +0000

description:
tests/lint: add test for constant argument to '!'

diffstat:

 tests/usr.bin/xlint/lint1/msg_239.c   |  17 ++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_239.exp |   5 ++++-
 2 files changed, 18 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 54532d97d073 -r c4ae5981ca9f tests/usr.bin/xlint/lint1/msg_239.c
--- a/tests/usr.bin/xlint/lint1/msg_239.c       Fri Apr 02 22:05:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_239.c       Fri Apr 02 22:38:42 2021 +0000
@@ -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;
+}
diff -r 54532d97d073 -r c4ae5981ca9f tests/usr.bin/xlint/lint1/msg_239.exp
--- a/tests/usr.bin/xlint/lint1/msg_239.exp     Fri Apr 02 22:05:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_239.exp     Fri Apr 02 22:38:42 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index