History log of /src/tests/usr.bin/xlint/lint1/msg_259.c |
Revision | | Date | Author | Comments |
1.25 |
| 09-Jun-2024 |
rillig | lint: warn about lossy floating point constant to integer conversions
|
1.24 |
| 08-Jun-2024 |
rillig | tests/lint: group tests by topic
|
1.23 |
| 09-Jul-2023 |
rillig | lint: remove redundant '#' after 'argument' in diagnostics
|
1.22 |
| 28-Mar-2023 |
rillig | lint: warn about extern declarations outside headers
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
|
1.21 |
| 17-Jun-2022 |
rillig | tests/lint: make 'expect+-' comments stricter
Previously, the expectations from these comments were already satisfied if the expectation occurred somewhere in the actual message from lint. This meant that the prefix 'error:' or 'warning:' could be omitted from the 'expect' comment. These omissions were hard to see in a manual review. Now any omissions must be visually marked with '...'.
The test msg_342 now reports its messages properly as being in the file msg_342.c, rather than msg_341.c. This had been a copy-and-paste mistake.
|
1.20 |
| 15-Apr-2022 |
rillig | lint: in C99 mode, do not warn about non-prototype conversions
Message 259 is "argument #%d is converted from '%s' to '%s' due to prototype", and it is intended to warn about compatibility between traditional C where functions had no prototypes and standard C where functions have prototypes.
Running lint in C99 mode is further away from traditional C than running lint in C90 mode, so that warning doesn't make sense for C99. There are still some inconsistencies in the 5 language version modes that lint offers:
-t for traditional C (no option) for migrating traditional C to C90 -s for C90 code -S for C99 code -Ac11 for C11 code
By disabling warning 259 in C99 mode, a typical NetBSD build produces 14.500 fewer warnings than before, of about 100.000 total.
Message 259 overlaps with message 298 "conversion from '%s' to '%s' may lose accuracy, arg #%d", and in some cases of potentially lossy conversions, lint now produces none of these messages. In some other cases, these warnings were reported redundantly. The cases where message 298 makes sense will be added back later, as needed.
|
1.19 |
| 02-Sep-2021 |
rillig | lint: align tests for message 259, clarify its purpose
|
1.18 |
| 02-Sep-2021 |
rillig | lint: fix unintended warning for converting long long to signed char
|
1.17 |
| 02-Sep-2021 |
rillig | tests/lint: demonstrate unintended prototype warning for signed char
|
1.16 |
| 31-Aug-2021 |
rillig | tests/lint: add cross-references to message 297
The check for lossy integer conversions is already implemented, it's just not activated in the default NetBSD build.
|
1.15 |
| 31-Aug-2021 |
rillig | tests/lint: add test for prototype conversions in C90
The purpose of warning 259 is to find function calls that differ in the ABI. The warning's original purpose was not to warn about lossy conversions, that's just a side effect.
Warning 259 had been implemented before C99 was published, which is more than 20 years ago. In the meantime, almost all code has migrated to using function prototypes. With the default lint flags from NetBSD's <sys.mk>, it would rather make sense to focus on lossy conversions now.
To prepare for potentially upcoming differences in lint's C90 and C99 modes, clone the test now as far as possible. The test for C90 mode is smaller than for C99 mode, since 'long long' was not available back then.
|
1.14 |
| 31-Aug-2021 |
rillig | tests/lint: add missing test cases for integer conversions
While adding the missing test cases, I re-read the comments and discarded several of them, since converting a signed value to an unsigned type can be lossy as well, which warrants a warning.
|
1.13 |
| 30-Aug-2021 |
rillig | tests/lint: test passing sizeof(int) to parameter type 'unsigned int'
Seen in usr.sbin/inetd/inetd.c, which calls getnameinfo and passes sizeof(buf).
|
1.12 |
| 21-Aug-2021 |
rillig | tests/lint: add more test cases for lossy integer conversion
|
1.11 |
| 21-Aug-2021 |
rillig | tests/lint: guard against typos in test environment configuration
Some tests had "lint1-only-if" without a trailing colon, others included the trailing colon. The tests that included the trailing colon were run even though they were supposed to be skipped, and they failed, as could be expected.
To prevent further typos, always require the trailing colon, just as in "lint1-flags" and fail fast on unknown "lint1" comments.
|
1.10 |
| 21-Aug-2021 |
rillig | tests/lint: add tests for conversion from signed to unsigned
|
1.9 |
| 04-Jul-2021 |
rillig | tests/lint: align tests for argument conversion to each other
|
1.8 |
| 29-Jun-2021 |
rillig | tests/lint: add test that only runs where char == unsigned char
There a 4 regular NetBSD builds where lint is activated. All these builds run on platforms where char == signed char.
The official test runs from https://releng.netbsd.org/test-results.html mostly have char == signed char as well.
However, lint behaves differently on platforms with char == unsigned char. On these platforms, a simple "char ch = '\xff'" leads to the bogus warning that "conversion of 'int' to 'char' is out of range".
|
1.7 |
| 29-Jun-2021 |
rillig | tests/lint: add tests for ILP32 platforms
Previously, all tests for lint had to produce the exact same output, no matter which platform they ran on. This differs from practical needs since lint is intended to produce different results depending on whether the platform is ILP32 or LP64.
Examples for these are type conversions and the widths of the integer types during lexical analysis.
|
1.6 |
| 04-Feb-2021 |
rillig | lint: update message text for 259 in test
That's the one place that is not checked for matching the actual message by my usual pre-commit checks.
|
1.5 |
| 04-Feb-2021 |
rillig | lint: add back "due to prototype" to message 259
That message is only supposed to warn about compatibility to traditional C, in case the function should ever be compiled without its prototype being in effect. All other type checks are supposed to be in another function, as documented, but that type check misses to report a few error-prone type combinations (long to char, long to int).
30 years after the introduction of prototypes with C90, almost all existing code uses prototypes. The warning has thus lost most of its usefulness and can rather be confusing since a conversion from 'char' to 'long' is not problematic with prototypes in action, and the probability of the code being backported to a pre-C90 compiler is diminishingly small.
The words "due to prototype" now serve as a hint again. The proper fix could be to suppress this warning in C99 mode since that's far enough from traditional C.
|
1.4 |
| 31-Jan-2021 |
rillig | lint: reword message 259 about function argument conversion
The words "due to prototype" are an anachronism from the 1990s. Nowadays every function is defined using a prototype, which makes these words redundant.
|
1.3 |
| 31-Jan-2021 |
rillig | lint: make warning about function argument conversion more detailed
For every conversion it is useful to know both the source and the target type since these are not always obvious from the code.
The only surprise is the warning in d_gcc_extension. The conversion there is from 'double' to 'long double', which is a lossless conversion. This may be a bug in lint.
|
1.2 |
| 30-Jan-2021 |
rillig | lint: add test for message 259 about implicit conversions
|
1.1 |
| 02-Jan-2021 |
rillig | lint: add a test for each message produced by lint1
Having a test for each message ensures that upcoming refactorings don't break the basic functionality. Adding the tests will also discover previously unknown bugs in lint.
The tests ensure that every lint message can actually be triggered, and they demonstrate how to do so. Having a separate file for each test leaves enough space for documenting historical anecdotes, rationale or edge cases, keeping them away from the source code.
The interesting details of this commit are in Makefile and t_integration.sh. All other files are just auto-generated.
When running the tests as part of ATF, they are packed together as a single test case. Conceptually, it would have been better to have each test as a separate test case, but ATF quickly becomes very slow as soon as a test program defines too many test cases, and 50 is already too many. The time complexity is O(n^2), not O(n) as one would expect. It's the same problem as in tests/usr.bin/make, which has over 300 test cases as well.
|