Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
lint: add more details to 'statement not reached' message In lib/libcompat/regexp/regexp.c, the FAIL macro expands to a compound statement containing a function call statement and a return statement, and the macro invocation is followed by a semicolon, forming an extra empty statement. Which of these statements is unreachable now becomes clear from the diagnostic, without having to inspect the preprocessed source code.
tests/lint: sort multiple diagnostics per line chronologically For now, the chronologic order is not enforced but has to be established manually, for example by removing all 'expect' comment lines and regenerating them with 'accept.sh -u'. While here, clean up a few instances that came up when regenerating the 'expect' comments, such as wrong indentation or needless deviation from the 'expect+1' form.
lint: warn about extern declarations outside headers https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
lint: properly clean up when leaving a function definition
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.
tests/lint: add more details to messages in msg_200 until msg_299 Add some tests that were previously empty. Some other tests are still empty.
lint: fix null pointer dereference after syntax error Found by afl, starting with the malformed input '/**/f=({;/**/};}' that no longer crashes. This input led to 'f=({L:;}', which is at least a syntactically valid prefix of a translation unit, containing a GCC statement expression with an unused label. The error message for this unused label assumed that it would always be inside a function definition. While here, document incomplete recovery after syntax errors, in msg_249.c.
lint: warn about unreachable null statements This warning flags the second semicolon of 'return;;' as being unreachable. It does not warn about these superfluous semicolons in general though. Seen in usr.bin/make/bmake_malloc.c.
lint: rename clrtyp/deftyp to begin_type/end_type The abbreviations clr/def did not make it obvious that these two functions or grammar rules form pairs. No functional change.
lint: do not allow struct{const;} In traditional C, a struct member was defined syntactically as 'type-specifier struct-declarator-list', the concept of a type-qualifier was not known back then. C90 invented the type-qualifier 'const' and relaxed the syntactic requirement for struct member declarations by allowing 'const x'. Having only a type-qualifier without an actual type may be regarded as an "incomplete type", which would be forbidden by C90 and later. Anyway, this doesn't occur in practice anyway, so there is no need for lint to try to parse it. This removes a bit of dead code, since a type-qualifier-list can never have type struct or union.
lint: fix assertion failure for malformed member declaration
tests/lint: test error recovery of the parser
tests/lint: add test coverage for some parse errors
lint: fix assertion failure after malformed statement Found using afl.
lint: force each test to declare the expected diagnostics By listing the expected diagnostics directly at the code that triggers the diagnostics, it is easier to cross-check whether the diagnostics make sense. No functional change to lint itself.
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.