1 1.4 rillig /* $NetBSD: msg_309.c,v 1.4 2021/05/16 10:18:25 rillig Exp $ */ 2 1.1 rillig # 3 "msg_309.c" 3 1.1 rillig 4 1.4 rillig // Test for message: extra bits set to 0 in conversion of '%s' to '%s', op '%s' [309] 5 1.1 rillig 6 1.3 rillig int 7 1.3 rillig scale(unsigned long long x) { 8 1.3 rillig 9 1.3 rillig /* 10 1.3 rillig * Both operands of '&' have the same type, therefore no conversion 11 1.3 rillig * is necessary and no bits can get lost. 12 1.3 rillig */ 13 1.3 rillig if ((x & 0xffffffff00000000ULL) != 0) 14 1.3 rillig return 32; 15 1.3 rillig 16 1.3 rillig /* 17 1.3 rillig * The constant has type 'unsigned 32-bit'. The usual arithmetic 18 1.3 rillig * conversions of '&' convert this constant to unsigned 64-bit. 19 1.3 rillig * The programmer may or may not have intended to sign-extend the 20 1.3 rillig * bit mask here. This situation may occur during migration from a 21 1.3 rillig * 32-bit to a 64-bit platform. 22 1.3 rillig */ 23 1.3 rillig if ((x & 0xffff0000) != 0) /* expect: 309 */ 24 1.3 rillig return 16; 25 1.3 rillig 26 1.3 rillig /* 27 1.3 rillig * In the remaining cases, the constant does not have its most 28 1.3 rillig * significant bit set, therefore there is no ambiguity. 29 1.3 rillig */ 30 1.3 rillig if ((x & 0xff00) != 0) 31 1.3 rillig return 8; 32 1.3 rillig if ((x & 0xf0) != 0) 33 1.3 rillig return 4; 34 1.3 rillig if ((x & 0xc) != 0) 35 1.3 rillig return 2; 36 1.3 rillig if ((x & 0x2) != 0) 37 1.3 rillig return 1; 38 1.3 rillig return (int)(x & 0x1); 39 1.3 rillig } 40