Home | History | Annotate | Line # | Download | only in lint1
msg_217.c revision 1.5
      1 /*	$NetBSD: msg_217.c,v 1.5 2021/03/21 11:48:04 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 int
     28 do_while_return(int i)
     29 {
     30 	do {
     31 		return i;
     32 	} while (0);
     33 }					/*FIXME*//* expect: 217 */
     34 
     35 /*
     36  * C99 5.1.2.2.3 "Program termination" p1 defines that as a special exception,
     37  * the function 'main' does not have to return a value, reaching the bottom
     38  * is equivalent to returning 0.
     39  *
     40  * Before func.c 1.72 from 2021-02-21, lint had wrongly warned about this.
     41  */
     42 int
     43 main(void)
     44 {
     45 }
     46