Module Name: src Committed By: rillig Date: Thu Sep 2 17:26:43 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_259.c msg_259.exp Log Message: tests/lint: demonstrate unintended prototype warning for signed char To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/xlint/lint1/msg_259.c cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/msg_259.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_259.c diff -u src/tests/usr.bin/xlint/lint1/msg_259.c:1.16 src/tests/usr.bin/xlint/lint1/msg_259.c:1.17 --- src/tests/usr.bin/xlint/lint1/msg_259.c:1.16 Tue Aug 31 19:26:23 2021 +++ src/tests/usr.bin/xlint/lint1/msg_259.c Thu Sep 2 17:26:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_259.c,v 1.16 2021/08/31 19:26:23 rillig Exp $ */ +/* $NetBSD: msg_259.c,v 1.17 2021/09/02 17:26:43 rillig Exp $ */ # 3 "msg_259.c" // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] @@ -12,6 +12,10 @@ /* lint1-extra-flags: -h */ void plain_char(char); +void signed_char(signed char); +void unsigned_char(unsigned char); +void signed_short(signed short); +void unsigned_short(unsigned short); void signed_int(int); void unsigned_int(unsigned int); void signed_long(long); @@ -39,6 +43,74 @@ change_in_type_width(char c, int i, long } /* + * The default argument promotions convert any small integer type to at + * least 'int', and without function prototypes, it is not possible to + * declare a function that has a parameter smaller than int, therefore + * these conversions do not produce any warnings. + * FIXME: Remove the warnings for 'signed char'. + * There are lossless conversions though, but these are covered by warning + * 297 instead. + */ +void +small_integer_types(char c, signed char sc, unsigned char uc, + signed short ss, unsigned short us, + signed int si, unsigned int ui, + signed long long sll, unsigned long long ull) +{ + plain_char(c); + plain_char(sc); + plain_char(uc); + plain_char(ss); + plain_char(us); + plain_char(si); + plain_char(ui); + plain_char(sll); + plain_char(ull); + + signed_char(c); + signed_char(sc); + signed_char(uc); + signed_char(ss); + signed_char(us); + signed_char(si); + signed_char(ui); + /* expect+1: warning: argument #1 is converted from 'long long' to 'signed char' due to prototype [259] */ + signed_char(sll); + /* expect+1: warning: argument #1 is converted from 'unsigned long long' to 'signed char' due to prototype [259] */ + signed_char(ull); + + unsigned_char(c); + unsigned_char(sc); + unsigned_char(uc); + unsigned_char(ss); + unsigned_char(us); + unsigned_char(si); + unsigned_char(ui); + unsigned_char(sll); + unsigned_char(ull); + + signed_short(c); + signed_short(sc); + signed_short(uc); + signed_short(ss); + signed_short(us); + signed_short(si); + signed_short(ui); + signed_short(sll); + signed_short(ull); + + unsigned_short(c); + unsigned_short(sc); + unsigned_short(uc); + unsigned_short(ss); + unsigned_short(us); + unsigned_short(si); + unsigned_short(ui); + unsigned_short(sll); + unsigned_short(ull); +} + +/* * Converting a signed integer type to its corresponding unsigned integer * type (C99 6.2.5p6) is usually not a problem since the actual values of the * expressions are usually not anywhere near the maximum signed value. From Index: src/tests/usr.bin/xlint/lint1/msg_259.exp diff -u src/tests/usr.bin/xlint/lint1/msg_259.exp:1.13 src/tests/usr.bin/xlint/lint1/msg_259.exp:1.14 --- src/tests/usr.bin/xlint/lint1/msg_259.exp:1.13 Tue Aug 31 19:26:23 2021 +++ src/tests/usr.bin/xlint/lint1/msg_259.exp Thu Sep 2 17:26:43 2021 @@ -1,24 +1,26 @@ -msg_259.c(37): warning: argument #1 is converted from 'long' to 'int' due to prototype [259] -msg_259.c(57): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259] -msg_259.c(60): warning: argument #1 is converted from 'long' to 'unsigned int' due to prototype [259] -msg_259.c(63): warning: argument #1 is converted from 'long long' to 'unsigned int' due to prototype [259] -msg_259.c(72): warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259] -msg_259.c(74): warning: argument #1 is converted from 'long long' to 'unsigned long' due to prototype [259] -msg_259.c(83): warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259] -msg_259.c(86): warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259] -msg_259.c(93): warning: argument #1 is converted from 'unsigned int' to 'int' due to prototype [259] -msg_259.c(95): warning: argument #1 is converted from 'unsigned long' to 'int' due to prototype [259] -msg_259.c(97): warning: argument #1 is converted from 'unsigned long long' to 'int' due to prototype [259] -msg_259.c(100): warning: argument #1 is converted from 'unsigned long' to 'long' due to prototype [259] -msg_259.c(102): warning: argument #1 is converted from 'unsigned long long' to 'long' due to prototype [259] -msg_259.c(105): warning: argument #1 is converted from 'unsigned long' to 'long long' due to prototype [259] -msg_259.c(107): warning: argument #1 is converted from 'unsigned long long' to 'long long' due to prototype [259] -msg_259.c(115): warning: argument #1 is converted from 'long' to 'int' due to prototype [259] -msg_259.c(117): warning: argument #1 is converted from 'long long' to 'int' due to prototype [259] -msg_259.c(121): warning: argument #1 is converted from 'long long' to 'long' due to prototype [259] -msg_259.c(124): warning: argument #1 is converted from 'long' to 'long long' due to prototype [259] -msg_259.c(133): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259] -msg_259.c(135): warning: argument #1 is converted from 'unsigned long long' to 'unsigned int' due to prototype [259] -msg_259.c(139): warning: argument #1 is converted from 'unsigned long long' to 'unsigned long' due to prototype [259] -msg_259.c(142): warning: argument #1 is converted from 'unsigned long' to 'unsigned long long' due to prototype [259] -msg_259.c(156): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259] +msg_259.c(41): warning: argument #1 is converted from 'long' to 'int' due to prototype [259] +msg_259.c(78): warning: argument #1 is converted from 'long long' to 'signed char' due to prototype [259] +msg_259.c(80): warning: argument #1 is converted from 'unsigned long long' to 'signed char' due to prototype [259] +msg_259.c(129): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259] +msg_259.c(132): warning: argument #1 is converted from 'long' to 'unsigned int' due to prototype [259] +msg_259.c(135): warning: argument #1 is converted from 'long long' to 'unsigned int' due to prototype [259] +msg_259.c(144): warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259] +msg_259.c(146): warning: argument #1 is converted from 'long long' to 'unsigned long' due to prototype [259] +msg_259.c(155): warning: argument #1 is converted from 'long' to 'unsigned long long' due to prototype [259] +msg_259.c(158): warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259] +msg_259.c(165): warning: argument #1 is converted from 'unsigned int' to 'int' due to prototype [259] +msg_259.c(167): warning: argument #1 is converted from 'unsigned long' to 'int' due to prototype [259] +msg_259.c(169): warning: argument #1 is converted from 'unsigned long long' to 'int' due to prototype [259] +msg_259.c(172): warning: argument #1 is converted from 'unsigned long' to 'long' due to prototype [259] +msg_259.c(174): warning: argument #1 is converted from 'unsigned long long' to 'long' due to prototype [259] +msg_259.c(177): warning: argument #1 is converted from 'unsigned long' to 'long long' due to prototype [259] +msg_259.c(179): warning: argument #1 is converted from 'unsigned long long' to 'long long' due to prototype [259] +msg_259.c(187): warning: argument #1 is converted from 'long' to 'int' due to prototype [259] +msg_259.c(189): warning: argument #1 is converted from 'long long' to 'int' due to prototype [259] +msg_259.c(193): warning: argument #1 is converted from 'long long' to 'long' due to prototype [259] +msg_259.c(196): warning: argument #1 is converted from 'long' to 'long long' due to prototype [259] +msg_259.c(205): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259] +msg_259.c(207): warning: argument #1 is converted from 'unsigned long long' to 'unsigned int' due to prototype [259] +msg_259.c(211): warning: argument #1 is converted from 'unsigned long long' to 'unsigned long' due to prototype [259] +msg_259.c(214): warning: argument #1 is converted from 'unsigned long' to 'unsigned long long' due to prototype [259] +msg_259.c(228): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]