1 1.3 rillig /* $NetBSD: msg_217.c,v 1.3 2021/01/31 13:33:10 rillig Exp $ */ 2 1.1 rillig # 3 "msg_217.c" 3 1.1 rillig 4 1.1 rillig // Test for message: function %s falls off bottom without returning value [217] 5 1.1 rillig 6 1.2 rillig int 7 1.2 rillig random(int n) 8 1.2 rillig { 9 1.2 rillig if (n < 0) 10 1.2 rillig return -3; 11 1.2 rillig } /* expect: 217 */ 12 1.3 rillig 13 1.3 rillig /* 14 1.3 rillig * The pattern 'do { } while (0)' is often used in statement macros. 15 1.3 rillig * Putting a 'return' at the end of such a macro is legitimate, the embracing 16 1.3 rillig * 'do { } while (0)' is probably there to conform to a coding standard or 17 1.3 rillig * to otherwise reduce confusion. 18 1.3 rillig * 19 1.3 rillig * Seen in external/bsd/libevent/dist/event_tagging.c, function 20 1.3 rillig * encode_int_internal. 21 1.3 rillig * 22 1.3 rillig * As of 2021-01-31, lint wrongly reports that the function would fall off 23 1.3 rillig * the bottom, but it cannot reach the bottom since every path contains the 24 1.3 rillig * 'return i'. 25 1.3 rillig */ 26 1.3 rillig int 27 1.3 rillig do_while_return(int i) 28 1.3 rillig { 29 1.3 rillig do { 30 1.3 rillig return i; 31 1.3 rillig } while (/*CONSTCOND*/0); /*FIXME*//* expect: 193 */ 32 1.3 rillig } /*FIXME*//* expect: 217 */ 33