Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
lint: do not convert array subscripts from size_t to ptrdiff_t The C standards do not specify a fixed type for an array subscript, it just has to be an integer type. Previously, query 4 fired for the ubiquitous expression 'ptr[sz]' when sz had type 'size_t'. The test platform_ilp32_long is unaffected by this change, as the integer constant 0x80000000 has type 'unsigned int', while size_t is 'unsigned long' on those platforms, and even though the types 'unsigned int' and 'unsigned long' have the same value space, there's still a conversion, at least for now.
lint: reword messages about array subscripts to sound more natural
lint: don't use 'long' in diagnostics The size of 'long' differs between 64-bit and 32-bit platforms. Eliminate this possible platform-dependency.
lint: warn about extern declarations outside headers https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
tests/lint: make expectation lines in the tests more detailed This commit migrates msg_100 until msg_199.
tests/lint: explain how lint represents pointer addition
lint: revert 'do not pre-multiply pointer expressions' from 2022-05-26 In tree.c 1.448, removing the pre-multiplication generated wrong warnings about out-of-bounds array access.
tests/lint: demonstrate wrong warning 'array subscript cannot be' Since tree.c 1.448 from 2022-05-26.
lint: fix initialization for arrays with designators From the previous commit, there was an off-by-one error left, which was due to the interaction between designation_add_subscript and extend_if_array_of_unknown_size. The other crucial point was to call initstack_pop_nobrace before accessing the "current initialization stack element". Without this call, in msg_168.c the "current element" would point to the initializer level for 'const char *' instead of the one for 'array of const char *'. One more step towards supporting C99.
lint: improve initialization of arrays with designators Initialization is still buggy but better than before. The remaining bug is that only the first designator determines the array size, and after that, the array is no longer considered of unknown size. This contradicts C99. More improvements to come.
tests/lint: demonstrate wrong warning for array subscript Seen in usr.bin/indent/lexi.c.
lint: add tests for a few messages
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.