1*465ab238Srillig /* $NetBSD: msg_373.c,v 1.4 2024/08/31 06:57:31 rillig Exp $ */ 238c0bdf2Srillig # 3 "msg_373.c" 338c0bdf2Srillig 438c0bdf2Srillig // Test for message: bit field end %ju in '%.*s' out of range 0..64 [373] 538c0bdf2Srillig 638c0bdf2Srillig /* 738c0bdf2Srillig * A bit-field may start in the middle of the value. When its end goes beyond 838c0bdf2Srillig * 64, this means the uppermost bits will always be 0, and a narrower 938c0bdf2Srillig * bit-field would have the same effect. 1038c0bdf2Srillig */ 1138c0bdf2Srillig 1238c0bdf2Srillig /* lint1-extra-flags: -X 351 */ 1338c0bdf2Srillig 1438c0bdf2Srillig typedef typeof(sizeof(0)) size_t; 1538c0bdf2Srillig typedef unsigned long long uint64_t; 1638c0bdf2Srillig 1738c0bdf2Srillig int snprintb(char *, size_t, const char *, uint64_t); 1838c0bdf2Srillig 1938c0bdf2Srillig void 2038c0bdf2Srillig example(uint64_t u64) 2138c0bdf2Srillig { 2238c0bdf2Srillig char buf[64]; 2338c0bdf2Srillig 241ec17c71Srillig /* expect+12: warning: field width '\101' (65) in 'f\000\101all+1\0' out of range 0..64 [372] */ 251ec17c71Srillig /* expect+11: warning: bit field end 65 in 'f\000\101all+1\0' out of range 0..64 [373] */ 261ec17c71Srillig /* expect+10: warning: bit field end 65 in 'f\001\100oob64\0' out of range 0..64 [373] */ 271ec17c71Srillig /* expect+9: warning: 'f\001\100oob64\0' overlaps earlier 'f\000\100all\0' on bit 1 [376] */ 2838c0bdf2Srillig /* expect+8: warning: field width '\377' (255) in 'f\010\377oob64\0' out of range 0..64 [372] */ 2938c0bdf2Srillig /* expect+7: warning: bit field end 263 in 'f\010\377oob64\0' out of range 0..64 [373] */ 3038c0bdf2Srillig snprintb(buf, sizeof(buf), 3138c0bdf2Srillig "\177\020" 3238c0bdf2Srillig "f\000\100all\0" 3338c0bdf2Srillig "f\000\101all+1\0" 3438c0bdf2Srillig "f\001\100oob64\0" 3538c0bdf2Srillig "f\010\377oob64\0", 3638c0bdf2Srillig u64); 373d5fc263Srillig 383d5fc263Srillig /* expect+5: warning: bit position '\377' (255) in 'f\377\002wrap-around\0' out of range 0..63 [371] */ 393d5fc263Srillig /* expect+4: warning: bit field end 257 in 'f\377\002wrap-around\0' out of range 0..64 [373] */ 403d5fc263Srillig snprintb(buf, sizeof(buf), 413d5fc263Srillig "\177\020" 423d5fc263Srillig "f\377\002wrap-around\0", 433d5fc263Srillig u64); 4438c0bdf2Srillig } 45