Commit Graph

6484 Commits

Author SHA1 Message Date
rillig 8d2e8478af lint: implement __builtin_offsetof for the simplest cases
Cases not covered:
1. C99 allows designators in the offsetof macro.
2. For packed types, the offset is likely to be incorrect.
2023-08-05 10:13:39 +00:00
rillig 2d4c92c54f tests/lint: fix test for packed structs on 32-bit platforms 2023-08-05 10:00:59 +00:00
rillig 222dcfd4cf tests/lint: test C99 printf conversion specifiers in lint2 2023-08-05 09:44:18 +00:00
riastradh cf9621ed16 memfd(2): Run all tests; don't stop after the first failure. 2023-08-05 08:05:16 +00:00
rin 2c57825720 t_siginfo:sigfpe_int: Adjust for GCC12
Do not use constant 1 as numerator to raise integer division by zero.
GCC >= 12 optimizes (1 / i) into (abs(i) == 1 ? i : 0), even for -O0.
2023-08-04 03:31:13 +00:00
andvar 506971ff58 fix typos in comments and one definition, mainly s/sucket/socket/. 2023-08-03 20:45:49 +00:00
rillig 0448d06008 lint: make '_Static_assert' only available in C11 or C23 mode 2023-08-03 18:48:42 +00:00
nia e6ea867424 Revert addition of epoll to libc until discussion concludes 2023-08-03 12:24:46 +00:00
rin 2fd4746018 audiotest: Appease GCC 12.3.0 -Wmisleading-indentation
It does not matter whether this statement is a part of this if-then
block or not, anyway. No binary changes.
2023-08-03 08:36:38 +00:00
rin bfa63a7066 t_etfs: Skip large_blk for system with page size > 8192
Work around kernel freeze reported as PR kern/55658 for
powerpc/ibm4xx (16K pages)
2023-08-03 03:21:56 +00:00
rin a5ca3916c3 t_getrandom: Fix false positives for short read(2)
This only affects really slooooow machines, 68030 for me :)
2023-08-03 03:18:12 +00:00
rillig 5e813441c0 lint: fix handling of unnamed function parameters 2023-08-02 21:11:35 +00:00
rillig f2bab28745 lint: fix plural form in message 150 2023-08-02 18:57:54 +00:00
rillig 039b010016 lint: distinguish between arguments and parameters 2023-08-02 18:51:25 +00:00
rillig 9192ff1d13 lint: simplify handling of old-style arguments 2023-08-02 05:44:27 +00:00
gutteridge c14f999a4e t_pollts.c: fix typo in a description string (NFC) 2023-08-01 23:41:54 +00:00
andvar 1e7139f024 fix RCSIDs. 2023-08-01 20:09:12 +00:00
rillig b525fc25f4 tests/lint: test packed and in-parameter declarations 2023-08-01 19:52:15 +00:00
mrg 1115bcb541 cdbw_output()'s 3rd argument must be a 16-byte char array, so pad the
string literals passed to it with enough nuls to make this true.

found by GCC 12.
2023-08-01 07:57:17 +00:00
rillig 322d30b80f tests/lint: test symbol lookup in unnamed bit-field member declaration 2023-07-31 20:52:26 +00:00
rillig ce02e259a4 lint: fix assertion failure after unnamed bit-field member
Since 2023-07-15.
2023-07-31 20:31:58 +00:00
christos 2c545067c7 Add EPOLL_CLOEXEC (Theodore Preduta) 2023-07-30 18:31:13 +00:00
riastradh 3b7c09b692 ld.elf_so: Add some known-answer tests for hash functions.
Make sure the testing mechanism detects the traditional overflow bug.
2023-07-30 09:22:02 +00:00
rin 123e052909 t_memfd_create: Fix printf-like format by using %zu for size_t, and
%jd for off_t with cast to intmax_t, respectively.
2023-07-29 16:24:35 +00:00
christos d3ba7ba3a2 Add tests for t_memfd_create and fix bug found by tests 2023-07-29 12:16:34 +00:00
rillig ed9a7a8560 lint: condense code for ending a function
No functional change.
2023-07-29 07:49:14 +00:00
rillig 6383202121 tests/lint: test declarations in C11 and C23 2023-07-28 22:05:44 +00:00
christos d11110f473 Add epoll(2) from Theodore Preduta as part of GSoC 2023 2023-07-28 18:18:59 +00:00
rillig cbde550f0f lint: allow 'thread_local' to be combined with 'static' 2023-07-25 16:56:35 +00:00
rillig 5008d0bca1 lint: reword message about non-constant initializer 2023-07-21 06:02:07 +00:00
rillig 6d841877fb tests/lint: document an example of a non-constant initializer 2023-07-21 05:51:12 +00:00
mrg 7ab3f5c310 provide more things needed by new subr_prf.c. 2023-07-18 06:37:55 +00:00
rillig 1e05010e5d lint: each member declarator may have attributes, not only the last one 2023-07-15 21:47:35 +00:00
rillig c147c2e884 tests/lint: test GCC attributes in member declarations 2023-07-15 21:40:03 +00:00
rillig df9c24dec3 lint: allow 'extern' and 'thread_local' to be combined 2023-07-15 16:17:37 +00:00
rillig c68209d3ed tests/lint: test 'extern thread_local' storage classes
Seen in external/mpl/bind/dist/lib/isc/pthreads/include/isc/thread.h:32.
2023-07-15 16:11:32 +00:00
rillig 914dc1bf88 lint: fix member lookup after GCC statement expression 2023-07-15 14:54:31 +00:00
rillig 9a2539b9eb lint: fix use-after-free bug in GCC statement expressions 2023-07-15 13:51:36 +00:00
rillig ef4646fea8 tests/lint: demonstrate use-after-free in GCC statement expression 2023-07-15 12:24:57 +00:00
rillig 2ab89be182 tests/lint: document how to reliably crash lint1 after a parse error 2023-07-15 09:53:46 +00:00
rillig b956127314 lint: add debug logging for memory management and the symbol table 2023-07-15 09:40:36 +00:00
rillig 95638de25a lint: clean up comments, add a test for the '?:' operator 2023-07-14 08:53:52 +00:00
rillig b81e1a9edf tests/lint: test duplicate type qualifiers in pointer types 2023-07-13 22:44:10 +00:00
riastradh 07b9e924e1 t_bitops: Show the bad results on failure. 2023-07-13 20:39:24 +00:00
rillig 78e3dd62e3 lint: in C23 mode, recognize the keyword 'thread_local' 2023-07-13 20:30:21 +00:00
rillig fe2ba0d5e5 lint: _Thread_local is a storage class, not a type qualifier 2023-07-13 19:59:08 +00:00
rillig bc10e9be9d lint: reject _Noreturn if it occurs in invalid places
C11 introduced _Noreturn as a function-specifier, not as a type
attribute.  The latter may occur in more places.
2023-07-12 18:26:04 +00:00
rillig 5e96f60f79 tests/lint: add test for _Noreturn from C11 2023-07-12 18:13:39 +00:00
rillig 032c24b4d9 lint: update wording in diagnostic for C99 2023-07-11 20:54:23 +00:00
riastradh a41503c83d t_clock_gettime: Avoid signed/unsigned comparison. 2023-07-09 19:19:40 +00:00
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