msg_217.c revision 1.6 1 /* $NetBSD: msg_217.c,v 1.6 2021/03/21 11:55:59 rillig Exp $ */
2 # 3 "msg_217.c"
3
4 // Test for message: function %s falls off bottom without returning value [217]
5
6 int
7 random(int n)
8 {
9 if (n < 0)
10 return -3;
11 } /* expect: 217 */
12
13 /*
14 * The pattern 'do { } while (0)' is often used in statement macros.
15 * Putting a 'return' at the end of such a macro is legitimate, the embracing
16 * 'do { } while (0)' is probably there to conform to a coding standard or
17 * to otherwise reduce confusion.
18 *
19 * Seen in external/bsd/libevent/dist/event_tagging.c, function
20 * encode_int_internal.
21 *
22 * Before tree.c 1.243 from 2021-03-21, lint wrongly reported that the
23 * 'while 0' was unreachable. This has been fixed by allowing the 'while 0'
24 * in a do-while-false loop to be unreachable. The same could be useful for a
25 * do-while-true.
26 *
27 * Before func.c 1.83 from 2021-03-21, lint wrongly reported that the function
28 * would fall off the bottom.
29 */
30 int
31 do_while_return(int i)
32 {
33 do {
34 return i;
35 } while (0);
36 }
37
38 /*
39 * C99 5.1.2.2.3 "Program termination" p1 defines that as a special exception,
40 * the function 'main' does not have to return a value, reaching the bottom
41 * is equivalent to returning 0.
42 *
43 * Before func.c 1.72 from 2021-02-21, lint had wrongly warned about this.
44 */
45 int
46 main(void)
47 {
48 }
49