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