Commit Graph

4945 Commits

Author SHA1 Message Date
rillig 95d33e8c9b lint: fix wrong warning about out-of-range value '\xff' for char
This only affects platforms where char has the same representation as
unsigned char.
2021-06-29 21:33:08 +00:00
rillig 1abf4d0075 lint: document where to fix the wrong warning for '\xff' 2021-06-29 14:19:51 +00:00
rillig b468abca3b 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".
2021-06-29 13:58:13 +00:00
rillig 02832e2456 tests/lint: add 'make accept' to update the expected output 2021-06-29 09:44:25 +00:00
rillig b7cb676ee4 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.
2021-06-29 09:19:17 +00:00
rillig 3df3cc9cd8 tests/lint: allow tests to be skipped depending on platform properties 2021-06-29 08:46:10 +00:00
rillig aed8aa9f4e tests/lint: add test for character constant using backslash-newline 2021-06-29 07:28:01 +00:00
rillig 48c9c61aae lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
2021-06-29 07:23:21 +00:00
rillig 0b52e712a6 tests/lint: add tests for the lexical analysis 2021-06-29 07:17:43 +00:00
rillig 61e921f9ea lint: in C99 mode, complain about implicitly declared functions
C99, foreword, p5, item 22 lists among the major changes from C90:
"remove implicit function declaration".
2021-06-28 11:27:00 +00:00
rillig d8a3f2eb44 lint: fix parse error for type 'void (*)[*]' 2021-06-28 11:09:35 +00:00
rillig 8b3bb5df80 lint: fix type name for prototype function without parameters 2021-06-28 10:29:05 +00:00
rillig 5953d76ca7 lint: add type information to message 155 (type mismatch) 2021-06-28 10:23:49 +00:00
rillig 3ce5ae23e6 lint: turn null pointer dereference into assertion failure
Originally I only needed a message that would output the type name from
an abstract-declarator (C99 6.7.6), to see whether lint interprets the
types correctly.

Message 155 looked like a good candidate, but it only revealed more
incomplete and untested code in lint.
2021-06-28 10:07:43 +00:00
rillig 4610aed791 lint: only accept assignment-expression in _Generic
That's what C11 says.
2021-06-28 07:55:05 +00:00
rillig 25b67a1f3a lint: fix parsing of _Generic selection expressions
Previously, lint accepted comma-expressions where only
assignment-expressions are allowed.

This change does not make a difference in practice though since lint is
usually only run on source code that properly compiles.  Nevertheless,
rather be precise and accurate since the grammar might some day be
reused on less reliable input.
2021-06-27 21:30:46 +00:00
rillig d4e4f03cef lint: fix type comparison in _Generic selection expressions
In the newly added test comma_expression, there were two distinct type
objects for the tspec DOUBLE.
2021-06-27 21:16:40 +00:00
rillig bd01cfcf51 lint: fix result type of _Generic expressions 2021-06-27 20:47:13 +00:00
rillig 806e4bc530 tests/lint: add test for _Generic with incompatible return types 2021-06-27 19:59:23 +00:00
rillig 2a55fba353 tests/lint: fix selection of the .exp-ln file
Since t_integration.sh 1.58 from today, the expected .ln output was not
detected anymore.  Changes to the file format would have gone unnoticed.
2021-06-27 19:41:15 +00:00
rillig e3ff15fb52 tests/lint: remove list of test names from t_integration
By convention, each *.c file in the source directory is a test case.

There is no need to list them individually and redundantly.

There is also no need to group the tests for the individual messages.
This ensures that each test is run in the regular builds.  Previously,
the test all_messages stopped after the first failure.
2021-06-27 19:33:25 +00:00
rillig cec0b2453a lint: require C11 for _Generic
This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".
2021-06-27 19:10:29 +00:00
rillig f1f9bbff8d lint: fix option -Ac11, add test for _Generic
Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99.  This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken.  Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression.  In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.
2021-06-27 18:48:45 +00:00
rillig 23e91a740d tests/lint: allow skipping individual tests
Depending on the platform, some tests do not make sense or produce
platform-dependent results.  Allow these tests to be marked as such.

For example, the test lex_integer.c only works on 64-bit platforms.
Therefore it is disabled on i386 for now since it prints different
warnings there.  Even better would be a "lint1-only-on-lpi32" toggle,
but that would need detection of 'sizeof(int)' at runtime.
2021-06-27 10:14:43 +00:00
rillig 9e9145368b tests/lint: rename expected .ln file to .exp-ln
This way, the hack for suffixes is no longer needed.
2021-06-27 09:22:31 +00:00
blymn 56c355ec57 Update the check files to account for fixes to addstr.c 2021-06-22 07:49:58 +00:00
blymn c507997beb Fix slk test and check files due to libcurses slk changes. 2021-06-22 07:29:16 +00:00
rillig 38b6e324bc lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial
commit in 1995.
2021-06-20 18:38:12 +00:00
rillig a389762758 tests/lint: remove outdated comment about '\0'
That comment was only needed for lex.c 1.38 from 2021-06-18, which was
fixed with lex.c 1.39 from 2021-06-19, just a day later.
2021-06-20 18:23:07 +00:00
rillig 06c9089455 tests/lint: document disappearance of bug in pop_member 2021-06-20 18:11:21 +00:00
rillig 513d7d3b4c tests/lint: test syntax error in initialization using designator
This test prepares the upcoming refactoring of the grammar.
2021-06-20 18:09:48 +00:00
rillig 2236887078 lint: fix crash on semantically wrong code in ({...})
Found by afl.
2021-06-20 11:42:25 +00:00
rillig c6433d2c1a lint: fix assertion failure on malformed struct declaration
Found using afl.
2021-06-20 11:24:32 +00:00
rillig c8d33d92f3 lint: fix endless loop on unfinished comment at EOF
Found using afl.
2021-06-19 20:25:57 +00:00
rillig 921647eafa lint: fix assertion after malformed for loop
Found using afl.
2021-06-19 19:59:01 +00:00
rillig 8873496543 lint: fix assertion failure in struct with unnamed member
Found using afl.
2021-06-19 19:49:15 +00:00
rillig e4ad66c589 lint: fix assertion failure after malformed statement
Found using afl.
2021-06-19 16:05:07 +00:00
rillig 0c0b119a5d lint: fix crash in malformed initialization 2021-06-19 15:51:11 +00:00
rillig 6054740bd7 lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further
on.

This reintroduces the endless loop in the lexer, but that must be fixed
in another way that doesn't destroy the error handling.
2021-06-19 08:37:18 +00:00
rillig 3ce615eb20 tests/lint: add test cases for lexical analysis 2021-06-19 08:30:08 +00:00
riastradh 8c3b7b40bb tests/net/if_wg: Only expect this to fail once!
Not sure how that happened, weird artefact of applying fuzzy patch
twice or something.
2021-06-17 12:45:58 +00:00
riastradh 8166eec586 tests/net/if_wg: Mark as flaky (PR kern/56252). 2021-06-17 12:16:09 +00:00
riastradh 38862c874c tests/fs/tmpfs: Print bad values on failure for diagnosis. 2021-06-17 00:03:05 +00:00
riastradh ef09d38031 tests/fs/vfs: Mark udf_renamerace_cycle flaky, PR kern/56253. 2021-06-16 23:58:07 +00:00
riastradh 5bdf84f048 tests/net/if_wg: Fix typo: $ifconfig, not $ifconfg. 2021-06-16 23:45:52 +00:00
rillig 9ae5848a4f tests/lint: sort the list of test cases
No functional change.
2021-06-16 10:21:51 +00:00
rillig 10626f16e6 tests/lint: clean up ATF test driver
No functional change.
2021-06-16 10:19:23 +00:00
blymn 8f62ace17e Restore the slk_wset test after fixing a but in libcurses. 2021-06-15 22:21:09 +00:00
rillig 20ceec4d9e tests/lint: add test for previous prototype declaration 2021-06-15 08:48:49 +00:00
rillig 7868dc4b88 tests/libcurses: fix argument handling for mvwget_wch
There's currently no test for that function, therefore no functional
change.
2021-06-13 21:54:51 +00:00