Home | History | Annotate | Line # | Download | only in lint1
      1 /*	$NetBSD: msg_211.c,v 1.9 2025/04/12 15:49:50 rillig Exp $	*/
      2 # 3 "msg_211.c"
      3 
      4 // Test for message: function has return type '%s' but returns '%s' [211]
      5 
      6 /* lint1-extra-flags: -X 351 */
      7 
      8 struct str {
      9 	int member;
     10 };
     11 
     12 int
     13 return_int(double dbl, void *ptr, struct str str)
     14 {
     15 	if (dbl > 0.0)
     16 		return dbl;
     17 	if (ptr != (void *)0)
     18 		/* expect+1: warning: invalid combination of integer 'int' and pointer 'pointer to void' for 'return' [183] */
     19 		return ptr;
     20 	if (str.member > 0)
     21 		/* expect+1: error: function has return type 'int' but returns 'struct str' [211] */
     22 		return str;
     23 	return 3;
     24 }
     25 
     26 enum A {
     27 	A
     28 };
     29 
     30 enum B {
     31 	B
     32 };
     33 
     34 enum A
     35 return_enum(enum B arg)
     36 {
     37 	/* expect+1: warning: function has return type 'enum A' but returns 'enum B' [211] */
     38 	return arg;
     39 }
     40