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 'do { ... } whi...



details:   https://anonhg.NetBSD.org/src/rev/ec492782a940
branches:  trunk
changeset: 952892:ec492782a940
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Feb 20 18:52:58 2021 +0000

description:
lint: add test for 'do { ... } while (false)' in strict bool mode

Right now, this variant of the popular macro pattern is flagged as
needing a /*CONSTCOND*/ annotation.  As with 'do { ... } while (0)',
there is nothing wrong with this pattern, therefore there should be no
warning.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c   |  18 +++++++++++++++++-
 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp |   2 ++
 2 files changed, 19 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r 038406ea98ea -r ec492782a940 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sat Feb 20 18:49:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c     Sat Feb 20 18:52:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_bool_strict.c,v 1.19 2021/02/20 18:49:26 rillig Exp $    */
+/*     $NetBSD: d_c99_bool_strict.c,v 1.20 2021/02/20 18:52:58 rillig Exp $    */
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -740,3 +740,19 @@
        println(repr[cond]);            /* expect: 337 */
        println(cond ? "yes" : "no");
 }
+
+void
+do_while_false(void)
+{
+       do {
+
+       } while (__lint_false); /*FIXME*//* expect: 161 */
+}
+
+void
+do_while_true(void)
+{
+       do {
+
+       } while (__lint_true);  /* expect: 161 */
+}
diff -r 038406ea98ea -r ec492782a940 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sat Feb 20 18:49:26 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp   Sat Feb 20 18:52:58 2021 +0000
@@ -162,3 +162,5 @@
 d_c99_bool_strict.c(716): operands of '==' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict.c(728): warning: expression has null effect [129]
 d_c99_bool_strict.c(740): right operand of '+' must not be bool [337]
+d_c99_bool_strict.c(749): warning: constant in conditional context [161]
+d_c99_bool_strict.c(757): warning: constant in conditional context [161]



Home | Main Index | Thread Index | Old Index