Commit Graph

5632 Commits

Author SHA1 Message Date
rillig 32b7a7ce5c tests/indent: test token '('
There are already some tests in token_lparen.c that need to be merged.
2022-02-13 12:04:37 +00:00
rillig dc5fc49783 tests/indent: demonstrate the poor handling of compound literals 2022-02-13 11:07:48 +00:00
rillig 74bde70120 indent: fix indentation of enum constants in typedef (since 2019-04-04)
The solution is not elegant since it adds a small state machine inside
the parser state, but at least these states only depend on the sequence
of token types and not on any other part of the parser state.

Reported in PR#55453.
2022-02-12 19:56:52 +00:00
rillig 3f3aed2ecb tests/indent: add another test for indentation of enum constants
To prevent an overzealous quick hack for indenting enum constants in a
typedef, as part of fixing PR#55453.
2022-02-12 19:46:56 +00:00
rillig 3bb21ee83b tests/indent: demonstrate wrong formatting of enum (since 2019-04-04)
Reported by me in PR#55453.
2022-02-12 13:38:29 +00:00
rillig 08650bcabe tests/lint: document where some C99 tests come from
These tests were added due to PR#45417.
2022-02-12 01:23:44 +00:00
rillig a3b73aeb65 lint: reword message about bit-field in a union
There is nothing illegal about a bit-field in a union, it is allowed by
C90, C99 and C11.

Fixes PR toolchain/53219.
2022-02-07 02:44:49 +00:00
rillig cdc3b2d88e tests/lint: add test for message 41 about bit-field in union
See PR toolchain/53219.
2022-02-07 02:39:10 +00:00
martin 0df09db48c Test mkdir(2) with one or more trailing slashes - this currently fails
for v7fs.
2022-02-01 18:27:24 +00:00
ryo aa60659cfa Extend the time to wait for the thread to quit.
It seems that alarm(1) is not enough time for the thread to actually exit after quittingtime = 1.
It randomly failed with "Test program received signal 14" on a slow environment.
2022-01-31 17:23:37 +00:00
andvar 7c674e8e6e remove double t from targeted, add missing r to arbitrary
And fix few more typos along the way in comments and man pages.
2022-01-26 11:48:53 +00:00
blymn b98cb8fe3d Remove excess shift since locale is no longer passed 2022-01-25 21:28:49 +00:00
blymn e00f184c11 Update of tests to account for output changes associated with wide char
fixes.  Also, default all tests to using UTF8 instead of doing a special
dance for the wide character tests and fix debug_test to force set the
locale to UTF8 so tests under debug don't throw spurious mismatches
when a wide character test is run.
2022-01-25 03:23:05 +00:00
rillig 81ed1247be tests/libc/inet: remove stray semicolons
No binary change.
2022-01-16 10:38:59 +00:00
rillig f0364de67e tests/lint: document why accidental double semicolons are hard to detect 2022-01-16 10:11:38 +00:00
rillig e50b89772c tests/lint: update comment to reality 2022-01-16 08:40:31 +00:00
rillig 990054f8df 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.
2022-01-15 23:21:34 +00:00
rillig 7c0fdb814d tests/lint: demonstrate undetected double semicolon
In a statement-list like 'return 0;;', the second semicolon is a
separate, unreachable statement.
2022-01-15 22:12:35 +00:00
rillig 3d28ebb279 tests/lint: fix comments 2022-01-15 17:33:42 +00:00
rillig a4a927ac8f tests/lint: expect complete messages in feature tests
Previously, the tests contained many comments like /* expect: 123 */,
which were useless to a casual reader since nobody is expected to learn
lint's message IDs by heart.  Replace these with the complete
diagnostics, to show what lint is complaining about.

The tests named msg_*.c have been left unmodified since they mention the
full message text in their header comment.

No functional change.
2022-01-15 14:22:03 +00:00
skrll f59dda2318 Trailing whitespace 2022-01-14 07:34:07 +00:00
andvar 000f65416a s/udpate/update/ 2022-01-07 22:59:32 +00:00
ozaki-r a349629228 tests: skip ndp_cache_state on qemu 2022-01-07 03:07:41 +00:00
andvar 3746949308 fix few typos in comments, mainly in word "parameter". 2021-12-31 20:22:48 +00:00
rillig 7e26407346 tests/lint: extend documentation for omitted braces in initializer 2021-12-28 22:54:08 +00:00
rillig ca061b3a21 lint: fix wrong error in strict bool mode in condition with comma
For the result of the comma operator, it doesn't matter whether the
comma itself comes from a system header or not.  Instead, it's the main
operator of the right operand.

Since 2021-11-16.
2021-12-22 15:36:37 +00:00
rillig 94d1e5f09d lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not
a whole keyword table.

Sync comment for lex_name with reality: sbuf_t no longer contains the
hash value.

Remove redundant tests for EOF, as EOF is neither a space nor a digit
nor an xdigit.

No functional change.
2021-12-22 15:20:08 +00:00
rillig 2c1fba9316 lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.

No binary change.
2021-12-22 14:49:11 +00:00
rillig 1cea36cfce tests/lint: improve test for initialization of array of unknown size
Previously, the test didn't show that the size of the resulting object
was updated too early.
2021-12-22 14:32:31 +00:00
rillig 7a458352ec lint: use C90 instead of C89 when referring to the C standard 2021-12-22 14:25:35 +00:00
rillig aae3cb7698 tests/lint: fix space-tab indentation 2021-12-22 14:11:14 +00:00
rillig 469bb78c7a lint: fix handling of initializations
The implementation from March 2021 added proper support for designators
but didn't model the brace levels correctly.  In particular, it could
not handle additional braces or omitted braces.  In such a case, lint
skipped the remaining initializers from the initialization.  Due to
this, type errors in the remaining initializers went unnoticed.  Another
effect was that arrays of unknown size were wrongly reported as having
size 0.

Both GCC and Clang recommend placing braces around each sub-type that is
initialized, such as a struct, union or array.  Postfix does not follow
these recommendations, therefore lint had to be disabled in
external/ibm-public/postfix/Makefile.inc.  This commit fixes the bugs
mentioned there.
2021-12-22 00:45:53 +00:00
rillig bc7377e5ab tests/lint: extend test for nested initializations 2021-12-21 23:12:21 +00:00
rillig ef2849da0a lint: reword message 187 about too long string literal for initializer
The previous message was imprecise in that it didn't distinguish between
non-terminating and terminating null bytes.
2021-12-21 22:21:11 +00:00
rillig 6bf50d6b33 lint: treat incomplete union in the same way as incomplete struct
The newly added tests triggered the assertion in begin_designation since
for incomplete types the initialization is stopped before handling the
first brace.
2021-12-21 21:42:21 +00:00
rillig 68d988e225 tests/lint: test initialization of incomplete union
The function initialization_lbrace only mentions STRUCT, which looks
suspicious.
2021-12-21 21:16:08 +00:00
rillig 764d028677 lint: make function names a bit more concise
No binary change.
2021-12-21 16:50:11 +00:00
rillig 0889d20275 tests/lint: remove false assumptions from comments
https://stackoverflow.com/q/65868752
2021-12-21 16:25:14 +00:00
rillig d161e75752 tests/lint: test excess braces around initializers 2021-12-20 19:48:05 +00:00
kre 357cae1e96 Compensate for changes made in mixerctl.c rev 1.29
Usage msg now appears on stderr, and causes exit status to be 1
2021-12-18 10:50:48 +00:00
rillig 63b80f5043 tests/lint: add more examples for initialization, from C99 2021-12-17 15:52:30 +00:00
rillig e0fcad7c02 lint: fix initialization with few braces from function
Seen in Postfix, smtp_proto.c.
2021-12-17 11:06:15 +00:00
rillig 25eb09be4f tests/lint: demonstrate another initialization with few braces
Seen in Postfix, smtp_proto.c.
2021-12-17 10:51:45 +00:00
rillig 9b48a2a756 lint: fix initialization of array with fewer braces
Seen in Postfix, cleanup_strerror.c.
2021-12-17 10:33:23 +00:00
rillig ee351844ad tests/lint: demonstrate another initialization that lint cannot handle
Seen in external/ibm-public/postfix/dist/src/global/cleanup_strerror.c.
2021-12-17 10:22:30 +00:00
rillig da62eac479 lint: work around lint bug in initialization with few braces
Needs a proper fix later, but for now, this workaround allows to run
lint on Postfix again.
2021-12-17 09:12:45 +00:00
rillig cd9e55e701 lint: demonstrate wrong error message in initialization
History of the new test fragment:

libexec/2021.09.14.19.44.40-plain/lint1
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| exit status 1
libexec/2021.04.01.14.20.30-plain/lint1

libexec/2021.03.30.20.23.30-plain/lint1
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'int' [185]
| (15): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| (15): error: cannot initialize 'struct typedef histogram_entry'
|     from 'int' [185]
| exit status 1
libexec/2021.03.30.14.25.28-plain/lint1

libexec/2021.03.29.21.34.17-plain/lint1
| (15): error: too many struct/union initializers [172]
| exit status 1
libexec/2021.03.28.15.36.37-plain/lint1

libexec/2021.03.28.14.13.18-plain/lint1
| (18): error: too many struct/union initializers [172]
| exit status 1
libexec/2021.03.21.20.44.59-plain/lint1

libexec/2021.03.21.20.30.19-plain/lint1
| (18): too many struct/union initializers [172]
| exit status 1
libexec/2014.11.20.20.49.06-plain/lint1

libexec/2014.11.20.20.48.33-plain/lint1
| exit status 0
2021-12-17 01:00:50 +00:00
rillig a8a62f37ee tests/lint: ensure that tests on a message mention this message 2021-12-16 21:14:58 +00:00
rillig 38da6713f9 tests/lint: fix test on platforms where char is unsigned
In tree.c 1.385 from 2021-10-09, the format of the message changed.  The
test for platforms where char is unsigned was not updated in that commit
because I had forgotten about it, and because lint1/check-msgs.lua only
checks the message in tests named exacty msg_000.c, but not msg_000_*.c.

Found by martin@.
2021-12-16 20:23:40 +00:00
martin c95b4819a5 Remove bogus architecture detection voodo - tsan is not available
on most architectures, so just state it that way.
2021-12-16 16:30:55 +00:00