msg_207.c revision 1.5
1/*	$NetBSD: msg_207.c,v 1.5 2024/11/13 04:32:49 rillig Exp $	*/
2# 3 "msg_207.c"
3
4// Test for message: loop not entered at top [207]
5
6static void
7/* expect+1: warning: static function 'for_loop' unused [236] */
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: 'init' 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}
52