1 /* $NetBSD: msg_132.c,v 1.5 2021/04/06 21:17:28 rillig Exp $ */ 2 # 3 "msg_132.c" 3 4 // Test for message: conversion from '%s' to '%s' may lose accuracy [132] 5 6 /* 7 * NetBSD's default lint flags only include a single -a, which only flags 8 * narrowing conversions from long. To get warnings for all narrowing 9 * conversions, -aa needs to be given more than once. 10 * 11 * https://gnats.netbsd.org/14531 12 */ 13 14 /* lint1-extra-flags: -aa */ 15 16 typedef unsigned char u8; 17 typedef unsigned short u16; 18 typedef unsigned int u32; 19 typedef unsigned long long u64; 20 21 typedef signed char i8; 22 typedef signed short i16; 23 typedef signed int i32; 24 typedef signed long long i64; 25 26 void 27 convert_unsigned(u8 v8, u16 v16, u32 v32, u64 v64) 28 { 29 v8 = v16; /* expect: 132 */ 30 v8 = v32; /* expect: 132 */ 31 v8 = v64; /* expect: 132 */ 32 33 v16 = v8; 34 v16 = v32; /* expect: 132 */ 35 v16 = v64; /* expect: 132 */ 36 37 v32 = v8; 38 v32 = v16; 39 v32 = v64; /* expect: 132 */ 40 41 v64 = v8; 42 v64 = v16; 43 v64 = v32; 44 } 45 46 void 47 convert_signed(i8 v8, i16 v16, i32 v32, i64 v64) 48 { 49 v8 = v16; /* expect: 132 */ 50 v8 = v32; /* expect: 132 */ 51 v8 = v64; /* expect: 132 */ 52 53 v16 = v8; 54 v16 = v32; /* expect: 132 */ 55 v16 = v64; /* expect: 132 */ 56 57 v32 = v8; 58 v32 = v16; 59 v32 = v64; /* expect: 132 */ 60 61 v64 = v8; 62 v64 = v16; 63 v64 = v32; 64 } 65 66 /* 67 * Before tree.c 1.268 from 2021-04-06, lint wrongly warned that conversion to 68 * _Bool might lose accuracy. C99 6.3.1.2 defines a special conversion rule 69 * from scalar to _Bool though. 70 */ 71 _Bool 72 to_bool(long a, long b) 73 { 74 /* seen in fp_lib.h, function wideRightShiftWithSticky */ 75 return a | b; 76 } 77