Home | History | Annotate | Line # | Download | only in lint1
msg_230.c revision 1.4
      1 /*	$NetBSD: msg_230.c,v 1.4 2021/07/03 19:31:22 rillig Exp $	*/
      2 # 3 "msg_230.c"
      3 
      4 // Test for message: nonportable character comparison, op %s [230]
      5 
      6 /* lint1-flags: -S -g -p -w */
      7 /* lint1-only-if schar */
      8 
      9 void example(char c, unsigned char uc, signed char sc)
     10 {
     11 	if (c < 0)
     12 		return;
     13 	/* expect+1: warning: comparison of unsigned char with 0, op < [162] */
     14 	if (uc < 0)
     15 		return;
     16 	if (sc < 0)
     17 		return;
     18 
     19 	/*
     20 	 * XXX: The comparison "<= -1" looks very similar to "< 0",
     21 	 * nevertheless "< 0" does not generate a warning.
     22 	 *
     23 	 * The comparisons may actually differ subtly because of the usual
     24 	 * arithmetic promotions.
     25 	 */
     26 	/* expect+1: warning: nonportable character comparison, op <= [230] */
     27 	if (c <= -1)
     28 		return;
     29 	/* expect+1: warning: comparison of unsigned char with negative constant, op <= [162] */
     30 	if (uc <= -1)
     31 		return;
     32 	if (sc <= -1)
     33 		return;
     34 }
     35