Home | History | Annotate | Line # | Download | only in lint1
msg_117.c revision 1.6
      1 /*	$NetBSD: msg_117.c,v 1.6 2021/08/15 13:02:20 rillig Exp $	*/
      2 # 3 "msg_117.c"
      3 
      4 // Test for message: bitwise '%s' on signed value possibly nonportable [117]
      5 
      6 /* lint1-extra-flags: -p */
      7 
      8 int
      9 shr(int a, int b)
     10 {
     11 	return a >> b;			/* expect: 117 */
     12 }
     13 
     14 int
     15 shr_lhs_constant_positive(int a)
     16 {
     17 	return 0x1234 >> a;
     18 }
     19 
     20 int
     21 shr_lhs_constant_negative(int a)
     22 {
     23 	return -0x1234 >> a;		/* expect: 120 */
     24 }
     25 
     26 int
     27 shr_rhs_constant_positive(int a)
     28 {
     29 	return a >> 0x1234;		/* expect: 117 *//* expect: 122 */
     30 }
     31 
     32 int
     33 shr_rhs_constant_negative(int a)
     34 {
     35 	return a >> -0x1234;		/* expect: 117 *//* expect: 121 */
     36 }
     37 
     38 unsigned int
     39 shr_unsigned_char(unsigned char uc)
     40 {
     41 	/* FIXME: This value cannot actually be negative. */
     42 	/* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
     43 	return uc >> 4;
     44 }
     45