Commit Graph

6484 Commits

Author SHA1 Message Date
rillig 62071d8c64 lint: in the warning about ordered enums, mention the affected type 2023-07-09 12:04:08 +00:00
rillig ea3322651c lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
2023-07-09 11:18:55 +00:00
rillig a194378b9e lint: clean up the wording of a few diagnostics 2023-07-09 11:01:27 +00:00
rillig 4a29af3e7e lint: remove redundant '#' after 'argument' in diagnostics 2023-07-09 10:42:07 +00:00
riastradh 42ba7a81e2 clock_gettime(2): Fix CLOCK_PROCESS/THREAD_CPUTIME_ID.
Use same calculation as getrusage, not some ad-hoc arithmetic of
internal scheduler parameters that are periodically rewound.

PR kern/57512

XXX pullup-8
XXX pullup-9
XXX pullup-10
2023-07-08 20:02:10 +00:00
rillig 486fcaa047 lint: warn about pointer casts between different kinds of types
Pointer casts from an integer type to a floating-point type and vice
versa get a 'maybe troublesome' warning now.  The previous assumption
that all types of the same bit-size are convertible may have been valid
from a technical point of view, but still such code should get more
attention.

The rules for struct and union types could be made more fine-grained
later, if the need arises.  To suppress this warning, it's always
possible to cast to an intermediate 'void *'.
2023-07-08 16:13:00 +00:00
riastradh d60bdbc1da t_timerfd: Sprinkle slightly more diagnostics.
Might help us to see if we're off by just a little bit (maybe a tiny
jitter between the hardclock timer and the monotonic clock), or if
something is seriously amiss when the timerfd_block test fails
sporadically.
2023-07-08 15:32:58 +00:00
rillig a03d49bac0 lint: do not use portable type sizes in integer constraints
This reverts the change from tree.c 1.547 from 2023-07-03.  Back then, I
didn't know that the actual value from a type's 'portable size in bits'
was not supposed to be used.
2023-07-08 15:26:25 +00:00
riastradh 3fe2e0724d t_clock_gettime: Add test for PR kern/57512. 2023-07-08 14:05:51 +00:00
rillig 1d389f0fa4 lint: warn about conversion from 128-bit to smaller integer types 2023-07-08 12:45:43 +00:00
rillig 5bb571bbdc tests/lint: demonstrate missing warning for converting int128_t 2023-07-08 12:42:11 +00:00
rillig 1d1794a80f tests/lint: fix a few ilp32 tests 2023-07-08 11:03:00 +00:00
rillig 223ac6e8ac tests/lint: automate accepting changed test results 2023-07-08 10:01:17 +00:00
rillig afb87394f6 tests/lint: only overwrite .exp files if the output actually changes 2023-07-08 08:02:45 +00:00
rillig e6298b924c lint: warn about function definitions without header declaration
The existing warning was only issued for function declarations, not for
function definitions.

The interesting change in the tests is in msg_351.c.  Many other tests
use non-static functions due to their syntactic brevity.  In these
tests, the warning is disabled individually, to allow new functions to
be added without generating warning 351.
2023-07-07 19:45:22 +00:00
rillig 06b8093259 lint: only skip 'unused' warnings after errors, not other warnings
Previously, in -w mode, any warning suppressed further 'unused'
warnings, even though there was no need to do that.  This can be seen in
the test gcc_attribute_var.c, where only the last unused variable from a
function was marked as unused, the others slipped through.

Fixed by counting the errors and the warnings separately and only
combining them if actually desired.
2023-07-07 06:03:31 +00:00
rillig 62962fdef2 tests/lint: test all combinations of {func,obj}_{decl,def}
For a non-static function definition that is not declared in a header,
lint doesn't currently warn.  The previous test didn't notice this.
2023-07-07 00:25:23 +00:00
rillig a9b749ce7a tests/lint: merge duplicate tests for C11 _Atomic 2023-07-07 00:20:39 +00:00
riastradh 7d87cccbb2 t_sig_backtrace: Flush stdout before writing to STDOUT_FILENO.
Avoids confusing ordering of output.
2023-07-06 20:44:55 +00:00
rillig bff65bdad9 tests/lint: ensure consistent preprocessor filenames in tests
The deviations often happen when copying or renaming tests.
2023-07-06 07:33:36 +00:00
riastradh d2876e0fc7 tests/libexec/ld.elf_so: Fix helper library makefiles.
1. Consolidate logic into a single helper.mk to reduce duplication.
2. Set NO* variables, not MK* variables which are reserved for user.
3. Avoid eager X!= in favour of lazy ${X:sh}.
4. Mark _g.a set list entries obsolete.  Never should've been built!

PR misc/57462
2023-07-05 22:42:46 +00:00
riastradh bf2cc18785 t_posix_memalign: Simplify.
No functional change intended.
2023-07-05 12:09:39 +00:00
riastradh ec5bc5eca5 t_posix_memalign: Fix this to reflect restriction lifted in C17. 2023-07-05 11:43:05 +00:00
rillig 1603ef6585 tests/lint: spell platform identifiers for 'long double' consistently
The test file names don't have a hyphen, so the identifiers shouldn't
have one either.
2023-07-05 11:42:14 +00:00
rillig 581fbf1bfe tests/lint: add platform-specific tests for troublesome pointer casts 2023-07-05 11:36:56 +00:00
riastradh 50dbd23a19 t_posix_memalign: Expand test cases and properties.
- Test cartesian product of a sampling of sizes and a sampling of
  alignments.

- Verify all the edge cases I could find in posix_memalign and
  aligned_alloc, including failure modes.

- Test an unreasonably large (but aligned) allocation size.

- Use ATF_CHECK_* instead of ATF_REQUIRE_* so all failures will be
  reported, not just the first one.

- While here, build with -fno-builtin-aligned_alloc and with
  -fno-builtin-posix_memalign to make sure the compiler doesn't try
  any shenanigans.

XXX pullup-10
2023-07-04 15:06:36 +00:00
rillig 353545ac36 lint: consistently use portable type size in integer constraints
Since tree.c 1.546 from 2023-07-03, lint no longer warned about possible
loss of accuracy when converting from 'long' to 'int' on an ILP32
platform that uses 'unsigned long' for size_t, when run in portable mode
(-p), which is enabled by default in the NetBSD build.

The integer constraints avoid false-positive warnings by looking at the
actual values an expression can take.  The function can_represent is
guarded by a condition that uses the portable_size_in_bits, but then
internally used the opposite size_in_bits, which led to inconsistent
results.

The warning looks confusing though, as on an ILP32 platform, 'int' and
'long' have the same size and representation, therefore there cannot be
an actual loss of accuracy.  The warning may need to be reworded to
explicitly mention the portability mode, in which sizeof(int) is assumed
to be 3 instead of 4, to catch possible loss of accuracy on other
platforms.
2023-07-03 21:36:16 +00:00
rillig 2bb36c1110 tests/lint: move platform-specific query tests to separate files
This fixes the tests on 'unsigned char' platforms.

Thanks martin@ for the notification.
2023-07-03 15:29:42 +00:00
rillig e5eea854b3 tests/lint: clean up tests for C99 bool 2023-07-03 09:37:14 +00:00
rillig 10bd4ec804 lint: fix C11 mode to not allow C23 features (since yesterday) 2023-07-03 09:33:07 +00:00
rillig 4f51279e58 lint: rename uppercase QUAD to LLONG
No binary change.
2023-07-03 07:03:19 +00:00
rillig a615f06cd9 tests/lint: add C23 tests 2023-07-02 23:45:10 +00:00
rillig 29b0195f9b lint: add initial support for C23
Required by xsrc/external/mit/MesaLib.old, brw_eu_validate.c, which
initializes a struct using empty braces: 'return (struct string){};'.
2023-07-02 23:40:23 +00:00
rillig e16f398bf1 lint: allow empty statements in GCC statement expressions 2023-07-02 22:56:13 +00:00
rillig 6ab24c0b4d tests/lint: demonstrate empty statement in GCC statement expression
Seen in external/mit/xorg/lib/dri.old.
2023-07-02 22:50:18 +00:00
rillig ad4700f62b lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
2023-07-02 18:14:44 +00:00
rillig 600fe2a7c7 tests/lint: rework tests for type names 2023-07-01 20:57:37 +00:00
rillig c6d4ed97fd lint: clean up typos 2023-07-01 09:21:31 +00:00
rillig 130b20d8de lint: fix initialization of unnamed union member 2023-07-01 06:09:24 +00:00
rillig 91f591a176 tests/lint: test initializing an unnamed union 2023-06-30 22:27:47 +00:00
rillig c7c89cb5fa lint: clean up names related to declaration levels
The previous prefix 'DK_' (declaration level kind) had a conflict with
the 'DK_' (designator kind) in init.c, so change the prefix to 'DLK_'.
The new name for dinfo_t is decl_level, which is more expressive.

No functional change.
2023-06-30 21:39:54 +00:00
rillig e50dbdf451 lint: fix handling of unnamed struct/union members
The support for unnamed struct/union members that was added in decl.c
1.60 from 2015-10-13 was simple but wrong. It didn't cover initializers
of these structures and computed wrong sizes for structures containing
anonymous unions. At that time, the handling of initializers was broken
as well, it was fixed 6 years later in init.c 1.229 from 2021-12-22.

Real-life examples for code that lint couldn't handle are:

	* external/bsd/jemalloc/dist/src/jemalloc.c
	* external/mit/xorg/lib/dri.old/Makefile
2023-06-30 21:06:18 +00:00
rillig f6c9a3ff5c lint: clean up handling of declarations
No functional change.
2023-06-30 19:10:49 +00:00
rillig fc9c97fa4c tests/lint: extend tests for sizeof and alignof 2023-06-30 16:39:17 +00:00
rillig cb8166a1d1 lint: fix computation of bit-field width
When bit-fields in packed structs were added on 2009-10-02, lint assumed
that they would only use 'signed int' or 'unsigned int' as storage unit,
even though C99 also allows _Bool.

The cleanup commit for decl.c 1.225 from 2021-08-28 accidentally changed
the rounding mode for bit-field storage units from round-up to
round-down.
2023-06-30 15:19:09 +00:00
rillig 9ae9809bbf lint: make alignof(incomplete enum) an error 2023-06-30 09:26:03 +00:00
rillig bf86468d4c tests/lint: add more tests for sizeof, offsetof, alignof 2023-06-30 09:21:52 +00:00
rillig 082684fd88 lint: add query for assigning an integer 0 to a pointer 2023-06-30 08:45:22 +00:00
rillig 7aaf3a0593 tests/lint: extend test for sizeof and offsetof 2023-06-30 08:03:01 +00:00
rillig 10704a6fff tests/lint: demonstrate bugs in anonymous struct/union handling 2023-06-30 07:18:02 +00:00
rillig aca02333cc tests/lint: demonstrate wrong size calculation in anonymous union 2023-06-28 21:41:27 +00:00
rillig 87eefb9092 tests/lint: do not overwrite expected files that only differ in spaces 2023-06-28 20:51:31 +00:00
rillig 15b1ffda11 tests/lint: fix preprocessor line number validation
When running the tests via ATF, the filename was an absolute filename,
while the preprocessing line in the test file uses a relative filename.
These two didn't match.
2023-06-28 17:53:21 +00:00
rillig b6d101e5c9 tests/lint: demonstrate wrong handling of nested initializer
Seen in external/bsd/jemalloc/dist/src/jemalloc.c, init_lock.
2023-06-28 15:04:07 +00:00
rillig 86d9dbede8 tests/lint: use standard form of ATF tests, test removing output file 2023-06-28 09:35:42 +00:00
rillig f6c6195c8b indent: fix 'blank line above first statement in function body' 2023-06-27 04:41:23 +00:00
rillig 36e71c5abd tests/indent: test the -badp option 2023-06-27 04:28:16 +00:00
rillig 45e235d0ba indent: improve heuristics for '*' as pointer in for loops 2023-06-26 20:23:40 +00:00
rillig 0982504e1c indent: improve heuristics for '*' as a pointer type 2023-06-26 20:10:23 +00:00
rillig f73b959d75 indent: implement 'blank line above first statement in function body' 2023-06-26 20:03:09 +00:00
rillig b54a4db2fc indent: in -bad mode, don't add a blank line above a comment or '}' 2023-06-26 14:54:40 +00:00
rillig eead40953d tests/indent: strengthen requirements for test input files
Previously, 'indent run-equals-prev-output' was allowed even when there
was no 'indent run' section above. This created an ambiguity, since
'previous output' could mean either the 'indent run' section or the
'indent run-equals-input' section.
2023-06-26 12:21:18 +00:00
rillig aa3872d78f tests/indent: extend test for -badp option 2023-06-26 11:01:08 +00:00
rillig ac483ee881 indent: treat 'complex' and 'imaginary' as type modifiers, not as types 2023-06-25 19:29:57 +00:00
rillig 9745d1edfa indent: fix formatting of parenthesized name in function definition 2023-06-25 19:19:42 +00:00
rillig 6ef27db9bc lint: don't warn about comparison between char and character constant 2023-06-24 17:50:31 +00:00
rillig 271d535ea8 lint: add query for comparing 'char' with plain integers 2023-06-24 08:11:12 +00:00
rillig a127f918f7 tests/lint: allow accept.sh to override lint1 for local testing 2023-06-24 07:45:36 +00:00
rillig 4a6e788063 lint: add query for redundant 'extern' in function declaration 2023-06-24 06:55:34 +00:00
msaitoh d1b93bab8c Fix typo in comment. 2023-06-24 05:27:13 +00:00
rillig 12dc98af47 indent: fix scanning of no-wrap comments (since 2021.11.07.10.34.03)
The "refactoring" back then tried to be too clever.
2023-06-23 20:59:04 +00:00
rillig f7b95e49e6 tests/indent: fix comments 2023-06-23 20:44:51 +00:00
rillig ec19c40c90 lint: add query for comma operator 2023-06-22 13:57:44 +00:00
rillig 69d93118ce tests/lint: comma operators are not allowed in constant expressions 2023-06-19 12:33:43 +00:00
knakahara 8d5cb09c67 Repair test coverage. I revert by proxy as the committer seems too busy to even reply mail.
TODO:
Provide some way for small machines to run subset test so that they get
shorter run time at the expense of test coverage.
2023-06-19 08:28:09 +00:00
rillig c4d462617d indent: only add blank lines before actual block comments 2023-06-18 07:32:33 +00:00
rillig 62ff1c97a7 indent: test block comments and the -bbb option 2023-06-18 07:29:36 +00:00
rillig 926f8bd544 indent: remove support for backspace in code and comments
The C code in the whole tree does not contain a single literal
backspace.
2023-06-18 07:10:24 +00:00
rillig 65e3242c1e tests/indent: add miscellaneous test cases found during clean up 2023-06-17 22:09:24 +00:00
rillig abc3274d3a indent: merge lexer symbols for type in/outside parentheses 2023-06-16 23:51:31 +00:00
rillig 95820b5370 tests/indent: format stderr output as end-of-line comments
This generates fewer error markers in syntax-aware editors.
2023-06-16 23:19:01 +00:00
rillig 398514d353 indent: fix spacing between postfix operator and left parenthesis 2023-06-16 23:07:52 +00:00
rillig 2fbaf64cd1 indent: improve heuristics for cast expressions 2023-06-16 14:26:26 +00:00
rillig 12ea422e44 indent: improve heuristics for cast expressions 2023-06-16 14:12:10 +00:00
rillig 961876df93 tests/indent: add a few code snippets from usr.bin/xlint 2023-06-16 13:43:30 +00:00
rillig 44e3c9f8ad indent: improve heuristics for casts 2023-06-16 12:55:57 +00:00
rillig 7983032213 indent: fix indentation and linebreaks in typedef declarations 2023-06-16 12:30:45 +00:00
rillig 128159d42b tests/indent: demonstrate wrong tokenization after typedef
Since 2023-06-10 06:52, which fixed the indentation of C11 _Generic
expressions.
2023-06-16 11:58:33 +00:00
rillig 8535e877f0 indent: don't force a blank line between '}' and preprocessing line 2023-06-16 11:48:32 +00:00
rillig 14063fa4b7 indent: fix indentation of multi-line enum constant initializers 2023-06-15 10:34:12 +00:00
rillig 0982fd88d1 indent: miscellaneous cleanups, more tests for edge cases 2023-06-15 09:19:06 +00:00
rillig f0cb29371b indent: fix alignment of multi-line declarations 2023-06-15 08:40:20 +00:00
rillig 940b85009c indent: clean up the code, add a few tests 2023-06-14 20:46:08 +00:00
rillig cdfe968337 indent: allow more than 128 brace levels 2023-06-14 19:05:40 +00:00
rillig ca9074275c tests/indent: separate stdout from stderr
Due to buffering, there was no guarantee that the output would be
exactly in the same order as written in the tests.
2023-06-14 17:07:32 +00:00
rillig 641fe74526 indent: allow more than 20 nested parentheses or brackets 2023-06-14 14:11:28 +00:00
rillig ddbd65a192 indent: fix formatting of comment after 'switch (expr)' 2023-06-14 11:18:09 +00:00
rillig 557ed6ed5d indent: use correct preprocessing directive in error message 2023-06-14 10:29:52 +00:00
rillig d2103f1c62 indent: allow more than 5 levels of #if/#endif 2023-06-14 10:26:00 +00:00
rillig ed7b435925 indent: clean up handling of comments
One less moving part in the parser state.

No functional change.
2023-06-14 09:31:05 +00:00
rillig 61c5d6b6d0 indent: remove a redundant flag from the parser state
No functional change.
2023-06-14 08:25:15 +00:00
rillig b2fe5a24a1 indent: merge parser symbols for stmt and stmt_list
They were handled in exactly the same way.
2023-06-14 07:20:54 +00:00
rillig bae713c412 indent: fix line break between semicolon and brace 2023-06-10 18:46:42 +00:00
rillig 3d124ccbbf tests/indent: add move coverage tests 2023-06-10 17:56:29 +00:00
rillig 8bcc07836b indent: fix stack overflow, add more tests
For several parser symbols, 2 symbols are pushed in a row, which led to
an out-of-bounds write.
2023-06-10 17:35:40 +00:00
rillig b3bf029a38 indent: miscellaneous cleanups 2023-06-10 16:43:55 +00:00
rillig f6ead5d9af indent: fix indentation of continuation lines in initializers 2023-06-10 08:17:04 +00:00
rillig 334e4e757d indent: explain right-aligned code 2023-06-10 07:05:18 +00:00
rillig f74eb54815 indent: fix token classification in declarations
As a side effect, indent handles _Generic from C11 properly now, at
least in -nlp mode.
2023-06-10 06:52:35 +00:00
rillig 338e471fd4 indent: rename and sort variables in parser state
No functional change.
2023-06-10 06:38:20 +00:00
rillig d3be4ec43d indent: trim trailing blank lines 2023-06-09 22:01:26 +00:00
rillig 1fc3c56ecf indent: support C99 compound literals 2023-06-09 11:22:31 +00:00
rillig ae40ebbc6b indent: don't treat function call expressions as cast expressions 2023-06-09 10:24:55 +00:00
rillig 1f304706fb indent: improve heuristics for function declaration vs. definition 2023-06-09 09:49:07 +00:00
rillig 1cc572504b tests/indent: add real-life test cases from make(1) and lint(1) 2023-06-09 09:45:55 +00:00
rillig eace873087 indent: when an indentation is ambiguous, indent one level further
The '-eei' mode now applies whenever the indentation from a multi-line
expression could be confused with a following statement.
2023-06-09 08:10:58 +00:00
rillig 2a0d16ddf2 tests/indent: test extra indentation in expressions 2023-06-09 07:54:05 +00:00
rillig 0fcafc89fc indent: preserve block comments with delimiters 2023-06-09 07:18:52 +00:00
rillig 5187119b0e indent: indent multi-line expressions according to parentheses
This reverts the FreeBSD change from 2004-02-12 that had been imported
on 2019-04-04.
2023-06-09 06:36:57 +00:00
rillig 7171fe25bf indent: remove fragile heuristic for detecting cast expressions
The assumption that in an expression of the form '(a * anything)', the
'*' marks a pointer type was too simple-minded.

For now, fix the obvious cases and leave the others for later.  If
needed, they can be worked around using the '-T' option.
2023-06-08 21:18:54 +00:00
rillig 5df2816aac indent: fix indentation of initializer lists with designators 2023-06-08 20:55:22 +00:00
rillig cfb043929d tests/indent: add more tests, from indent's own code 2023-06-08 20:49:04 +00:00
rillig 6b78dc3375 indent: fix indentation in multi-line else-if conditions 2023-06-08 20:36:35 +00:00
rillig 0663d70d1e tests/indent: extend test for wrong indentation in 'else if' 2023-06-08 20:28:50 +00:00
rillig 41e7f68d7c indent: clean up and condense code
No functional change.
2023-06-08 06:47:13 +00:00
rillig 9f9251e958 indent: right-trim single-line comments 2023-06-06 07:51:35 +00:00
rillig 5bf8b14793 tests/indent: comments with trailing whitespace may fit in a single line 2023-06-06 05:39:49 +00:00
rillig 6da4319099 indent: compute indentation of 'case' labels on-demand
One less moving part to keep track of.

No functional change.
2023-06-06 04:37:26 +00:00
rillig e14544c8e6 tests/indent: add test for left-justifying declarations 2023-06-05 15:02:54 +00:00
rillig 9a8371330c indent: don't remove blank line after 'if (expr) {' 2023-06-05 12:01:33 +00:00
rillig 24133b796d indent: do not report broken lines, report configuration on stderr 2023-06-05 10:12:21 +00:00
rillig abcf191e28 indent: fix formatting of 'do' statements 2023-06-05 09:41:40 +00:00
rillig b33c0a568f indent: fix trailing whitespace after comment 2023-06-05 08:22:00 +00:00
rillig 452673c116 tests/indent: add tests for 'do-while' loops 2023-06-05 08:10:25 +00:00
rillig a28f6dc620 indent: clean up handling of whitespace
No functional change.
2023-06-05 07:23:03 +00:00
rillig f38db2caee indent: do not parse '&&&&&&&' as a single binary operator 2023-06-04 22:57:18 +00:00
rillig 6bf97c9eba indent: fix '*=' to be a binary operator, not a unary one 2023-06-04 22:36:10 +00:00
rillig e071ed3c05 tests/indent: cover code in lexi.c 2023-06-04 22:20:04 +00:00
chs 3f4a55cf50 The ATF design is O(N^2) in the number of TCs in one TP, which on some
slower platforms causes the net/ipsec tests to take as much as 30% of
the total time to run all of the ATF tests.  Reduce the number of TCs
in various net/ipsec TPs by iterating over *_ALGORITHMS_MINIMUM rather
than *_ALGORITHMS.  Various of the net/ipsec tests already use the
smaller lists, so change the rest of them to do so as well.
2023-06-04 22:18:47 +00:00
rillig f84beafc1f tests/indent: clean up comments 2023-06-04 19:28:54 +00:00
rillig 3540994a6c indent: force at least one space after the colon of a label 2023-06-04 18:58:30 +00:00
rillig 43aa4f997a indent: rename struct field, for better symmetry
No binary change outside debug mode.
2023-06-04 14:20:00 +00:00
rillig 2c1771512e indent: fix indentation of initializers in compound expressions 2023-06-04 13:49:00 +00:00
rillig 1f543254ee indent: fix formatting of compound expressions, at least partially 2023-06-04 13:26:06 +00:00
rillig 08090a1872 lint: use separate lexer symbols for 'case' and 'default'
It's not strictly necessary since these tokens behave in the same way,
still, the code is more straight-forward when there are separate tokens.
2023-06-04 12:46:57 +00:00
rillig 27051cd2e2 indent: classify 'inline' as a modifier rather than a word 2023-06-04 11:45:00 +00:00
joerg 3caa8dc735 Fix interactions of initial-exec TLS model and dlopen
(1) If an initial-exec relocation was used for a non-local symbol
(i.e. the definition of the symbol is in a different DSO), the
computation of the static TLS offset used the wrong DSO.
This would effectively mean the wrong address was computed
(PR toolchain/50277, PR pkg/57445).

Fix this by forcing the computation of the correct DSO (the one defining
the symbol).

This code uses __UNCONST to avoid the vast interface changes for this
special case.

(2) If symbols from a DSO loaded via dlopen are used with both
global-dynamic/local-dynamic and initial-exec relocations AND
a initial-exec relocation was resolved first in a thread, a split brain
situation could exist where the dynamic relocations would use one memory
block (separate allocation) and the initial-exec relocations the static
per-thread TLS space.

(3) If the initial-exec relocation in (2) is seen after any thread has
already used a GD/LD allocation, bail out. Since IE relocations are used
only in the GOT, this will prevent the dlopen. This is a bit more
aggressive than necessary, but a full blown reference counting doesn't
seem to be justified.
2023-06-04 01:24:56 +00:00
rillig 0bee435acd indent: fix indentation of adjacent '{' 2023-06-03 21:44:08 +00:00
lukem 58beaa2b43 adapt to ${CC_WNO_MAYBE_UNINITIALIZED}
Use ${CC_WNO_MAYBE_UNINITIALIZED} instead of
the older style more complex expressions.

Remove workarounds if they were for a specific
version of gcc < 10.
2023-06-03 21:31:45 +00:00
lukem 1a214827c2 adapt to ${CC_WNO_FORMAT_TRUNCATION} 2023-06-03 21:28:52 +00:00
rillig 79e55a0f42 lint: add query for static variables in functions
This query allows finding hidden global variables, as an easier-to-read
alternative to 'objdump -t'.
2023-06-03 21:08:06 +00:00
rillig f9624b3c8d lint: provide more detailed types when operands do not match 2023-06-03 20:28:54 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
Rename compiler-warning-disable variables from
	GCC_NO_warning
to
	CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 09:09:01 +00:00
lukem f937c412f3 bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER
Provide a single variable
	CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
	CLANG_NO_ADDR_OF_PACKED_MEMBER
	CC_NO_ADDR_OF_PACKED_MEMBER
	GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 08:52:53 +00:00
riastradh 067c5136b3 ld.elf_so: Test dynamic-then-static abuse via ctor.
XXX pullup-10
2023-06-02 19:09:11 +00:00
riastradh f4e534dd53 ld.elf_so: Test another edge case of mismatched TLS models.
One library defines a symbol and _doesn't_ use it, so it has no
indication of whether the symbol is for static TLS or dynamic TLS,
and then two other libraries use it in different ways.

XXX pullup-10
2023-06-02 19:08:48 +00:00
riastradh 4dedd5fc26 ld.elf_so: tls_extern dynamic_defabuse_eager must xfail differently.
If a symbol has already been resolved as dynamic TLS, any library
that tries to use it as static TLS cannot be dlopened.

XXX pullup-10
2023-06-02 19:08:01 +00:00
rillig 3eeca426f5 indent: force each statement on a new line
Previously, '{} while (cond)' was kept on a single line, even though the
'while' was independent of the '{}'.
2023-06-02 15:07:46 +00:00
rillig 9e6f62d1d8 indent: remove newline between 'switch' and '{' 2023-06-02 14:34:14 +00:00
rillig 6fc430af5c indent: improve heuristics of classifying '*' as pointer or operator 2023-06-02 14:21:55 +00:00
rillig ef25c88e9b indent: clean up
Only print the 'token' buffer in debug mode if it is interesting, group
the blocks in handling of '(' tokens by topic, remove obsolete comment
from test.
2023-06-02 13:59:33 +00:00
rillig a565c86f6c indent: fix formatting of declarations with preprocessing lines 2023-06-02 11:43:07 +00:00
rillig 7511320300 tests/indent: demonstrate bugs when formatting preprocessing lines 2023-06-02 11:26:21 +00:00
andvar cb40c69b16 follow the steps of Andrew Doran (ad) commit and fix more s/loose/lose/ typos.
also s/beyound/beyond/ and few others along the way, mainly in comments.
2023-06-02 08:51:46 +00:00
riastradh 98256cacf3 ld.elf_so: Separately test eager and lazy resolution of def tls ptr.
eager: before loading use library
lazy: after loading use library

XXX pullup-10
2023-06-01 23:47:24 +00:00
riastradh e04ffa379b ld.elf_so: Shorter test names.
No functional non-cosmetic change intended.

XXX pullup-10
2023-06-01 22:26:51 +00:00
riastradh 6b7ae3bea1 ld.elf_so: Test TLS abuse of static def, dynamic use and vice versa.
XXX pullup-10
2023-06-01 22:26:40 +00:00
riastradh bc9d9d1143 ld.elf_so: Factor out logic in TLS tests to make writing more easier.
No functional change intended.

XXX pullup-10
2023-06-01 22:24:52 +00:00
riastradh 05e97b5a42 ld.elf_so: Test extern dynamic TLS too.
XXX pullup-10
2023-06-01 20:50:18 +00:00
riastradh f4e155a450 ld.elf_so: Test variations on PR toolchain/50277.
XXX pullup-10
2023-06-01 20:48:30 +00:00
riastradh fca22ba5cb ld.elf_so: Nix inadvertently committed private test program. 2023-05-31 01:06:43 +00:00
riastradh 111bb99c35 ld.elf_so: Fix extern TLS test to match PR toolchain/50277.
Now it's actually testing the problem.
2023-05-31 00:46:11 +00:00
riastradh 12037d6a69 ld.elf_so: New test for extern initial-exec TLS, PR toolchain/50277.
XXX pullup-10
2023-05-31 00:18:44 +00:00
hannken b3a4996943 Add RUMPHIJACK option "blanket=/DEV" so mount_ffs may canonicalise
and mount the device path.  Cannot use "/rump/DEV" here as the device
path is embedded in "struct ufs_args" where it doesnt get hijacked.
2023-05-28 08:17:00 +00:00
christos 562596981f match the new compiler warning 2023-05-24 20:02:34 +00:00
christos c59fd10753 no more md5 for you. 2023-05-24 18:22:05 +00:00
rillig e9b5780b33 indent: fix indentation of struct declarations 2023-05-23 16:53:57 +00:00
rillig fadc996fc6 indent: fix spacing around '*' in declarations 2023-05-23 06:43:19 +00:00
rillig 756425c686 indent: fix spacing in declarations in for loops 2023-05-23 06:35:01 +00:00
rillig 3368225913 tests/indent: add code snippets found in make and lint1 2023-05-23 06:18:00 +00:00
rillig 8bd40c7adb indent: fix spacing between block braces 2023-05-22 23:03:16 +00:00
rillig 9bf982382f tests/indent: refine a few tests 2023-05-22 23:01:27 +00:00
rillig 27a3cefcf0 tests/lint1: allow whitespace in files containing the expected output
This reduces the amount of wizardry needed to interpret the files.  For
a more gentle introduction of the file format, see ../lint2/msg_000.ln.

The whitespace that is removed is very similar to the one in the lint2
tests, the difference is that '%<space>' and '%#' need to be preserved
in abbreviated printf and scanf format strings.
2023-05-22 20:11:24 +00:00
rillig 960cfb1b4e lint: fix emitted type for arrays of unknown size 2023-05-22 17:53:27 +00:00
rillig f14ab694cd lint: rename constant NOTSPEC to NO_TSPEC
It was too easy to misread the old name as NOT_SPEC instead of the
intended NO_TSPEC.
2023-05-22 12:55:04 +00:00
rillig 9379c1663f tests/lint: demonstrate wrong emitted array length in initialization
Seen in usr.bin/indent/debug.c, in the various 'name' arrays.
2023-05-22 11:51:46 +00:00
rillig b95ee04d96 indent: implement suppressing optional blank lines 2023-05-22 10:28:59 +00:00
rillig 0df62e5bf6 tests/indent: skip creating an intermediate file in tests 2023-05-22 06:35:56 +00:00
andvar e7745f3aff s/thar/that/ in comments. 2023-05-21 18:01:38 +00:00
rillig c99fb69e72 tests/indent: fix outdated or wrong comments 2023-05-21 10:18:44 +00:00
rillig 4779b6fb88 indent: don't error out on unrecognized preprocessor directives
This allows indent to be used on the GCC preprocessor output.
2023-05-21 09:48:22 +00:00
rillig 89b72942a5 tests/indent: prevent 'indent end' with arguments 2023-05-20 22:08:07 +00:00
rillig a9183f83be tests/indent: migrate test driver from AWK to Lua
Lua reports more details when os.execute fails, which is useful when
running old versions of indent for comparison.  The new test driver also
supports multiple test files in the same run.
2023-05-20 21:32:05 +00:00
rillig 04185e831b tests/indent: clean up test driver
No functional change.
2023-05-20 17:31:53 +00:00
rillig fe2fb3c8db indent: don't insert blank line between two closing lines 2023-05-20 12:05:01 +00:00
rillig 5a9a628018 indent: implement blank line above block comment 2023-05-20 11:19:17 +00:00
rillig 1764a17f2c indent: implement blank line after function body 2023-05-20 10:46:21 +00:00
rillig c7613eff0b indent: ensure that no blank lines are inserted in INDENT OFF mode
No blank lines were inserted previously, but the code looked
suspicious as if that were possible.
2023-05-20 10:25:47 +00:00
rillig 4d19140d48 indent: implement blank lines around conditional compilation 2023-05-20 10:09:02 +00:00
rillig 895746d7ed tests/indent: test multi-line comments with -ncdb 2023-05-19 07:05:26 +00:00
rillig d46fdfe393 indent: document the funcname token 2023-05-18 08:09:28 +00:00
rillig 2d18db1bfc indent: manually wrap overly long lines
No functional change.
2023-05-18 05:33:27 +00:00
gutteridge b1f970ed17 t_ptm.c: add a test case that passes extra flags
Validate that O_NONBLOCK and O_CLOEXEC are actually set by
posix_openpt(3), as until circa 9.99.101 they were not.

If/when other flags are added like close-on-fork, this test could be
adjusted. The current concern is with supporting the expectations of
components like vte3, used by various graphical terminal clients.
2023-05-17 03:16:11 +00:00
rillig 81c7fd789d indent: remove support for form feed characters inside a line
Form feeds are occasionally used to split code into pages, and this use
is still supported.  Having a form feed in the middle of a line is
exotic.
2023-05-16 11:32:01 +00:00
rillig db245c79a9 indent: remove blank between comment and parentheses or brackets
Finally, indent formats its own source code without messing up the
layout.
2023-05-16 08:22:11 +00:00
rillig c5b428c7c1 indent: fix handling of INDENT OFF/ON comments
Previously, the 'INDENT OFF' comments were interpreted when the newline
token from the line above the comment was processed, which was earlier
than could be reasonably expected.

The 'INDENT ON' comments were interpreted equally early, which led to
the situation that the 'INDENT OFF' comments were preserved literally
but the 'INDENT ON' comments weren't.
2023-05-16 08:04:03 +00:00
rillig 70c3f641d2 indent: fix detection of casts
A word followed by a '(' does not start a cast expression.
2023-05-15 21:51:45 +00:00
rillig 62d29170f1 indent: fix type cast in function definition 2023-05-15 20:50:37 +00:00
rillig a59ea3192b indent: fix duplicate space between comment and binary operator 2023-05-15 20:30:20 +00:00
rillig 2aaa93dadf indent: fix line wrapping of comments to the right of code 2023-05-15 19:55:51 +00:00
rillig 219ccf6233 indent: improve type guessing, fix formatting of declarations 2023-05-15 18:22:40 +00:00
rillig 3357d7dc84 tests/indent: test type detection 2023-05-15 17:51:49 +00:00
rillig 2e1f799d6b indent: remove accidental space before tab 2023-05-15 17:38:56 +00:00
rillig 3842fd14e5 indent: remove backslash line continuation outside preprocessing
The indenter did not handle these backslashes well, interpreting them as
unary operators, and they are an edge case anyway.  Line continuations
in string literals and character constants are kept.
2023-05-15 17:28:14 +00:00
rillig c3a01c7bfa tests/indent: demonstrate wrong spacing after function prototype 2023-05-15 15:04:48 +00:00
rillig 6c38484f82 indent: fix spacing between function prototype and attributes 2023-05-15 14:55:47 +00:00
rillig c74302075d indent: fix indentation of struct member names 2023-05-15 14:12:03 +00:00
rillig 415b6afa14 tests/indent: demonstrate wrong indentation of struct members 2023-05-15 13:53:32 +00:00
rillig b33d7ae266 indent: fix indentation of statements after controlling expression 2023-05-15 13:33:19 +00:00
rillig 60722870c9 tests/indent: add another test for -eei -nlp 2023-05-15 13:28:05 +00:00
rillig 8bbe0ac207 indent: fix indentation of expressions in -nlp -eei mode 2023-05-15 12:59:43 +00:00
rillig 3801fbef33 tests/indent: test extra indentation with fixed continuation indentation 2023-05-15 12:11:07 +00:00
rillig 09166ed3ac indent: fix indentation of multi-line '?:' expressions in functions 2023-05-15 10:13:40 +00:00
rillig e311e1f8e6 tests/indent: -badp should not add blank lines in initializers 2023-05-15 09:05:08 +00:00
rillig 89e0e636cf indent: fix spacing in for loop with declaration (since 2022-02-13) 2023-05-15 08:56:39 +00:00
rillig f382e6fe26 tests/indent: demonstrate wrong spacing in for loops 2023-05-15 08:22:23 +00:00
rillig 9a2185a149 indent: clean up memory and buffer management
Remove the need to explicitly initialize the buffers.  To avoid
subtracting null pointers or comparing them using '<', migrate the
buffers from the (start, end) form to the (start, len) form.  This form
also avoids inconsistencies in whether 'buf.e == buf.s' or 'buf.s ==
buf.e' is used.

Make buffer.st const, to avoid accidental modification of the buffer's
content.

Replace '*buf.e++ = ch' with buf_add_char, to avoid having to keep track
how much unwritten space is left in the buffer.  Remove all safety
margins, that is, no more unchecked access to buf.st[-1] or appending
using '*buf.e++'.

Fix line number counting in lex_word for words that contain line breaks.

No functional change.
2023-05-15 07:28:45 +00:00
rillig 506e3bec5c indent: only null-terminate the buffers if necessary
The only case where a buffer is used as a C-style string is when looking
up a keyword.

No functional change.
2023-05-14 22:26:37 +00:00
rillig 1304bdca7f indent: fix handling of multiple block comments in a line 2023-05-14 17:53:38 +00:00
rillig 217e4d847d indent: in comments, keep a leading tab
This kind of comments is used for the CVS IDs at the top of files.
2023-05-14 17:13:37 +00:00
rillig 0cd0431ee6 indent: fix vertical spacing after declarations
A comment is not supposed to change the state of the 'blank line after
declaration', but it did.  The initialization of saved_just_saw_decl was
wrong though since it tried to capture the previous value after it had
already been overwritten.
2023-05-14 16:47:06 +00:00
rillig e04d6833e7 indent: miscellaneous cleanups 2023-05-14 11:29:23 +00:00
rillig 4f2a635091 lint: add query for chained assignments 2023-05-13 20:55:44 +00:00
riastradh 1e9b358f6a openssl: More tests need -Wno-missing-field-initializers. 2023-05-13 17:46:09 +00:00
rillig c49e59f750 indent: do not add a space before a comment that starts a line 2023-05-13 16:40:18 +00:00
rillig 2261e976c8 indent: implement 'blank after declarations' 2023-05-13 15:34:22 +00:00
riastradh 61b8d55f2a openssl: libcrypto bf test needs -Wno-missing-field-initializers 2023-05-13 15:12:13 +00:00
rillig 4cae730b26 tests/indent: extend test for blank line after declaration 2023-05-13 14:19:14 +00:00
rillig 24dd152d37 indent: fix lexing of numbers that are spread over multiple lines 2023-05-13 13:31:37 +00:00
rillig 9db90c6e6b tests/indent: add test for lexing of numbers 2023-05-13 13:24:01 +00:00
rillig 842f73039b indent: clean up a condition, add comments
No functional change.
2023-05-13 09:40:47 +00:00
rillig 38caea9b89 indent: preserve indentation of preprocessor directives 2023-05-13 08:33:39 +00:00
rillig ff059387ed tests/indent: explain, clean up and add some tests 2023-05-13 06:52:48 +00:00
rillig 8ba922e8f2 tests/indent: test pushing the placeholder symbol to the parser stack 2023-05-12 22:36:15 +00:00
rillig 0cdf93c9f3 indent: remove statistics
The numbers from the statistics were wrong.
2023-05-12 10:53:33 +00:00
rillig 46afda1643 tests/indent: test interaction between preprocessing and comments 2023-05-11 21:36:31 +00:00
rillig d5678748c0 indent: don't touch comments in preprocessing lines
The indentation of multi-line comments was wrong, and the code for
handling them was too complicated.
2023-05-11 19:01:35 +00:00
rillig bacb7fc4b5 tests/indent: add more tests for preprocessing directives 2023-05-11 18:44:14 +00:00
rillig 5300eef1a9 tests/indent: test multi-line comments in preprocessing lines 2023-05-11 18:36:36 +00:00
rillig d54ae284ce indent: remove broken code for handling blank lines
This fixes several bugs where blank lines were erroneously added or
removed, treating these old bugs for new bugs in different places.
These new bugs are expected to be easier to fix, as the old bugs will
not interfere anymore.
2023-05-11 18:13:55 +00:00