msg_217.c revision 1.4 1 /* $NetBSD: msg_217.c,v 1.4 2021/02/21 09:17:55 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 * As of 2021-01-31, lint wrongly reports that the function would fall off
23 * the bottom, but it cannot reach the bottom since every path contains the
24 * 'return i'.
25 */
26 int
27 do_while_return(int i)
28 {
29 do {
30 return i;
31 } while (/*CONSTCOND*/0); /*FIXME*//* expect: 193 */
32 } /*FIXME*//* expect: 217 */
33
34 /*
35 * C99 5.1.2.2.3 "Program termination" p1 defines that as a special exception,
36 * the function 'main' does not have to return a value, reaching the bottom
37 * is equivalent to returning 0.
38 *
39 * Before func.c 1.72 from 2021-02-21, lint had wrongly warned about this.
40 */
41 int
42 main(void)
43 {
44 }
45