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

This commit is contained in:
rillig 2021-04-02 22:38:42 +00:00
parent 473375a8eb
commit c0d1467e66
2 changed files with 18 additions and 4 deletions

View File

@ -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;
}

View File

@ -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]