1 /* $NetBSD: msg_259.c,v 1.12 2021/08/21 11:58:12 rillig Exp $ */ 2 # 3 "msg_259.c" 3 4 // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] 5 6 /* lint1-only-if: lp64 */ 7 /* lint1-extra-flags: -h */ 8 9 void farg_char(char); 10 void farg_int(int); 11 void farg_long(long); 12 13 void 14 example(char c, int i, long l) 15 { 16 farg_char(c); 17 farg_int(c); 18 /* No warning 259 on LP64, only on ILP32 */ 19 farg_long(c); 20 21 farg_char(i); /* XXX: why no warning? */ 22 farg_int(i); 23 /* No warning 259 on LP64, only on ILP32 */ 24 farg_long(i); 25 26 farg_char(l); /* XXX: why no warning? */ 27 /* expect+1: from 'long' to 'int' due to prototype [259] */ 28 farg_int(l); 29 farg_long(l); 30 } 31 32 void farg_unsigned_int(unsigned int); 33 void farg_unsigned_long(unsigned long); 34 void farg_unsigned_long_long(unsigned long long); 35 36 /* 37 * Converting a signed integer type to its corresponding unsigned integer 38 * type (C99 6.2.5p6) is usually not a problem. A common case where it 39 * occurs is when the difference of two pointers is converted to size_t. 40 */ 41 void 42 convert_to_corresponding_unsigned(int i, long l, long long ll) 43 { 44 /* TODO: don't warn here. */ 45 /* expect+1: warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259] */ 46 farg_unsigned_int(i); 47 48 /* TODO: don't warn here. */ 49 /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259] */ 50 farg_unsigned_long(l); 51 52 /* TODO: don't warn here. */ 53 /* expect+1: warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259] */ 54 farg_unsigned_long_long(ll); 55 56 /* 57 * XXX: Why no warning? Even though 'unsigned long' is 64 bits 58 * wide, it cannot represent negative 32-bit values. 59 */ 60 farg_unsigned_long(i); 61 62 /* 63 * XXX: Why no warning? Even though 'unsigned long long' is 64 bits 64 * wide, it cannot represent negative 32-bit values. 65 */ 66 farg_unsigned_long_long(i); 67 68 /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259] */ 69 farg_unsigned_long_long(l); 70 } 71