Home | History | Annotate | Line # | Download | only in lint1
      1 /*	$NetBSD: msg_306.c,v 1.6 2025/02/20 21:53:28 rillig Exp $	*/
      2 # 3 "msg_306.c"
      3 
      4 // Test for message: constant %s truncated by conversion, op '%s' [306]
      5 
      6 /* lint1-extra-flags: -X 351 */
      7 
      8 signed char s8;
      9 unsigned char u8;
     10 
     11 void
     12 msg_306(void)
     13 {
     14 	u8 = 0xff;
     15 	/* expect+1: warning: constant truncated by assignment [165] */
     16 	u8 = 0x100;
     17 
     18 	u8 &= 0xff;
     19 	/* expect+1: warning: constant 0x100 truncated by conversion, op '&=' [306] */
     20 	u8 &= 0x100;
     21 	/* XXX: Lint doesn't care about the expanded form of the same code. */
     22 	u8 = u8 & 0x100;
     23 
     24 	u8 |= 0xff;
     25 	/* expect+1: warning: constant 0x100 truncated by conversion, op '|=' [306] */
     26 	u8 |= 0x100;
     27 	/* XXX: Lint doesn't care about the expanded form of the same code. */
     28 	u8 = u8 | 0x100;
     29 
     30 	s8 &= 0xff;
     31 	/* expect+1: warning: constant 0x100 truncated by conversion, op '&=' [306] */
     32 	s8 &= 0x100;
     33 	/* XXX: Lint doesn't care about the expanded form of the same code. */
     34 	s8 = s8 & 0x100;
     35 	s8 |= 0xff;
     36 	/* expect+1: warning: constant 0x100 truncated by conversion, op '|=' [306] */
     37 	s8 |= 0x100;
     38 	/* XXX: Lint doesn't care about the expanded form of the same code. */
     39 	s8 = s8 | 0x100;
     40 }
     41