Fri Apr 19 20:59:18 2024 UTC (19d)
tests/lint: show how to trigger message 207


(rillig)
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_207.c

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_207.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_207.c 2022/06/16 21:24:41 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_207.c 2024/04/19 20:59:18 1.4
@@ -1,8 +1,51 @@ @@ -1,8 +1,51 @@
1/* $NetBSD: msg_207.c,v 1.3 2022/06/16 21:24:41 rillig Exp $ */ 1/* $NetBSD: msg_207.c,v 1.4 2024/04/19 20:59:18 rillig Exp $ */
2# 3 "msg_207.c" 2# 3 "msg_207.c"
3 3
4// Test for message: loop not entered at top [207] 4// Test for message: loop not entered at top [207]
5 5
6/* expect+1: error: syntax error ':' [249] */ 6static void
7TODO: "Add example code that triggers the above message." 7/* expect+1: warning: static function 'for_loop' unused [236] */
8TODO: "Add example code that almost triggers the above message." 8for_loop(void)
 9{
 10 for (int i = 0; i < 10; i++)
 11 if (0 == 1)
 12 for (i = 0;
 13 i < 5;
 14 /* expect+2: warning: loop not entered at top [207] */
 15 /* expect+1: warning: end-of-loop code not reached [223] */
 16 i += 4)
 17 return;
 18
 19 // XXX: Why is this different from the snippet above?
 20 for (int i = 0; i < 10; i++)
 21 if (0 == 1)
 22 /* expect+1: warning: statement not reached [193] */
 23 for (int j = 0;
 24 j < 5;
 25 /* expect+1: warning: end-of-loop code not reached [223] */
 26 j += 4)
 27 return;
 28}
 29
 30static void
 31/* expect+1: warning: static function 'while_loop' unused [236] */
 32while_loop(void)
 33{
 34 for (int i = 0; i < 10; i++)
 35 if (0 == 1)
 36 /* expect+1: warning: loop not entered at top [207] */
 37 while (i < 5)
 38 i += 4;
 39}
 40
 41static void
 42/* expect+1: warning: static function 'do_loop' unused [236] */
 43do_loop(void)
 44{
 45 for (int i = 0; i < 10; i++)
 46 if (0 == 1)
 47 /* expect+1: warning: loop not entered at top [207] */
 48 do {
 49 i += 4;
 50 } while (i < 5);
 51}