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
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
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
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
rillig
0bee435acd
indent: fix indentation of adjacent '{'
2023-06-03 21:44:08 +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
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
christos
562596981f
match the new compiler warning
2023-05-24 20:02:34 +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
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
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
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
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
rillig
3ae5a30b3c
indent: add debug output for tracking comments and braces
2023-05-11 17:22:56 +00:00
rillig
44c1f7b6a8
indent: remove unnecessary assignments to last_else
...
No functional change intended.
2023-05-11 10:39:25 +00:00
rillig
373317666b
indent: remove buggy code for swapping tokens
...
It is not the job of an indenter to swap tokens, even if it's only about
placing comments elsewhere. The code that swapped the tokens was
complicated, buggy and impossible to understand.
In -br (brace right) mode, indent no longer moves a '{' from the
beginning of a line to the end of the previous line, as that was handled
by the token swapping code as well. This change is unintended, but it
will be easier to re-add that now that the code is simpler.
2023-05-11 09:28:53 +00:00
rillig
0510ee8e2a
lint: fix type name in diagnostic for enum as controlling expression
...
Previously, the type was reported as 'int' instead of 'enum'.
Continue to only report the type simple for pointer types, as the exact
pointer type is irrelevant to this message.
2023-05-11 08:01:36 +00:00
rillig
a48523a624
lint: track integer constraints through conditional expressions
2023-05-09 15:51:33 +00:00
rillig
872d56a969
lint: preserve integer constraints on cast
2023-05-09 15:45:06 +00:00
rillig
b889b215f6
tests/lint: demonstrate wrong warning about loss of accuracy
2023-05-09 15:37:29 +00:00
rillig
815f75fc84
tests/lint: demonstrate wrong warning about losing accuracy
2023-05-09 14:46:36 +00:00
gutteridge
09bc0ce2d8
t_sed.sh: add a test case for relative addressing
...
At one time, this didn't always work correctly, per PR bin/49109. Test
case from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192108
2023-05-06 02:12:11 +00:00
gutteridge
f12d9a9c2d
t_sed.sh: fix grammar, spelling, and formatting issues (NFC)
2023-05-06 02:07:42 +00:00
rillig
0878a3d7ee
lint: reword message for missing declaration in header
...
Suggested by Christos.
2023-04-25 19:00:57 +00:00
rillig
951d064816
tests/lint: add rationale for not warning about alignment problems
2023-04-23 11:52:43 +00:00
rillig
f0ae73e148
lint: be strict when parsing command line for excluded message IDs
...
Previously, lint accepted -X '1, 2, 3', while the manual page lists the
IDs without spaces.
On 32-bit platforms, lint accepted -X -4294967295, and on 64-bit
platforms, it accepted the corresponding larger numbers.
The code for parsing message IDs and query IDs conceptually does the
same, but the implementations differed for no reason.
2023-04-23 09:04:44 +00:00
rillig
1d3cf26e0d
tests/lint: test command line parsing for message and query IDs
...
The parsing methods differ but shouldn't.
2023-04-23 08:47:27 +00:00
rillig
6b952c1471
lint: allow cast from a type to a union containing that type
2023-04-22 20:54:28 +00:00
rillig
368afe279d
lint: fix wrong warning about 'extern' temporary identifier
2023-04-22 20:27:09 +00:00
rillig
da9016a31f
tests/lint: demonstrate wrong warning about extern temporary identifier
2023-04-22 20:21:13 +00:00
rillig
a143ec617b
tests/lint: test cast to union with stricter alignment
2023-04-22 19:45:04 +00:00
rillig
b847195210
lint: don't warn about cast between union and one of its member types
...
Seen in src/sbin/newfs_udf/udf_core.c for context.anchors.
2023-04-22 17:42:29 +00:00
rillig
0e61302acd
tests/lint: add test for conversions to and from a union type
...
Additionally, fix the line numbers in another test.
2023-04-22 17:30:35 +00:00
rillig
83d27b7d33
lint: do not warn about parenthesized assignment in controlling expr
...
Same as for GCC and Clang.
2023-04-22 15:14:37 +00:00
rillig
5fe653032c
tests/lint: remove wrong comment
...
GCC 10 does warn about returning a temporary object, but only when
optimizations are enabled.
2023-04-15 12:59:02 +00:00
rillig
db7f32c2b2
tests/lint: add more tests for returning local objects
2023-04-15 12:47:32 +00:00
rillig
408e7ca205
lint: add query for parenthesized return value
2023-04-15 11:34:45 +00:00
rillig
e7d3b23c6b
tests/lint: extend test for returning local address
2023-04-15 10:53:59 +00:00
rillig
484ed28712
lint: don't wrongly warn about overflow in complex constants
...
Seen in lib/libm.
2023-04-11 00:03:42 +00:00
rillig
f8bad61ed5
tests/lint: demonstrate wrong warning with complex numbers
2023-04-10 23:52:49 +00:00
rillig
f92802e558
lint: fix duplicate warning when parsing big float constants
2023-04-05 20:17:30 +00:00
rillig
cc35e66604
tests/lint: demonstrate duplicate warning when parsing big floats
2023-04-05 20:13:01 +00:00
rillig
ce2e717784
lint: allow querying for octal integer constants
2023-03-31 13:03:05 +00:00
rillig
d0a5c1bc3c
lint: warn about 'extern' declarations inside function bodies
...
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
The previous attempt (message 351 about 'extern' declarations outside
headers) did not cover the proposal from the tech-userlevel mailing list
but instead warns about a different usage pattern of the 'extern'
keyword.
2023-03-28 20:04:51 +00:00
rillig
b2baa50111
lint: warn about extern declarations outside headers
...
https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
2023-03-28 14:44:34 +00:00
rillig
eaf30a03e7
lint: split platform-specific test for loss of accuracy
...
Lint distinguishes between platforms where size_t is unsigned int and
platforms where size_t is unsigned long.
2023-02-27 23:07:53 +00:00
rillig
17f65f1e9a
tests/lint: sync test for nonportable character comparisons
...
Message 230 was changed on 2023-02-22 but only tested on signed char
platforms.
2023-02-27 21:59:14 +00:00
sjg
68f52b2486
t_make skip varname-dot-make-meta-ignore_*
...
The meta-ignore tests will likely not work in this environment
so skip them.
2023-02-25 19:37:33 +00:00
rillig
6adfeb9415
lint: fix confusing message about nonportable character constants
2023-02-22 22:30:40 +00:00
rillig
f29e29e219
tests/lint: add platform-specific tests
2023-02-22 22:12:35 +00:00
rillig
68d13a7aa7
lint: fix null pointer dereference in invalid case expression
2023-02-21 19:47:21 +00:00
rillig
4995df0909
lint: do not warn about traditional C migration in C99 mode
...
For large integer constants, the resulting type could differ between
traditional C and C90. In C99 mode, this difference is no longer
relevant since it is too far away from traditional C.
2023-02-19 12:00:15 +00:00
rillig
a44d0c3164
tests/lint: fix and extend tests for C90 migration warning
2023-02-19 11:50:29 +00:00
rillig
8ee241b006
lint: remove compat code for lexing hex floating point literals
...
Hex floating literals are required by C99.
2023-02-18 14:32:32 +00:00
rillig
15a1e93882
tests/lint: sync reference to platform properties generator
2023-02-06 21:20:58 +00:00
rillig
456342a5d0
lint: eliminate unnecessary indirection
...
No functional change.
2023-02-06 21:01:55 +00:00
rillig
f1b2140bb8
tests/lint: fix source directory for looking up the .exp-ln files
2023-02-05 17:23:01 +00:00
rillig
6d1c4d2bf4
tests/lint1: the redundantly listed files contained .exp-ln as well
2023-02-05 16:11:56 +00:00
rillig
d81c1a19b2
tests/lint: fix resolving of wildcards in builds from other directories
2023-02-05 15:11:19 +00:00
rillig
cd59f013cc
tests/lint: merge tests for initialization
2023-02-05 13:01:28 +00:00
rillig
6730036cf8
tests/lint: remove redundancy from Makefile
...
The list of test files is already kept in distrib/sets/lists/tests/mi.
2023-02-05 12:36:56 +00:00
rillig
134e5c5e76
tests/lint: remove redundant tests
...
The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.
2023-02-05 12:25:11 +00:00
rillig
9de3085848
tests/lint: clean up
...
The .exp files are no longer kept under version control, so there's no
reason anymore to forcefully trigger a warning or an error.
2023-02-05 10:57:48 +00:00
rillig
e0bb9f7cf5
lint: properly clean up when leaving a function definition
2023-01-29 18:37:20 +00:00
rillig
b5b35fa5a0
lint: fix definition of __func__
2023-01-29 18:16:48 +00:00
rillig
e80194217c
lint: demonstrate wrong declaration of __func__
2023-01-29 17:36:26 +00:00
rillig
2f05763014
lint: don't warn about negative '>>' when the actual value is positive
2023-01-29 17:13:10 +00:00
rillig
6b8b6837b1
tests/lint: merge tests for '>>'
2023-01-29 17:02:09 +00:00
rillig
b4db8a2cd2
tests/lint: document how compilers promote bit-fields
2023-01-28 08:36:17 +00:00
rillig
93f3a70d97
tests/lint: investigate how compilers interpret bit-fields
2023-01-28 08:30:12 +00:00
rillig
f25c712f32
tests/lint: merge tests for declaration after statement
2023-01-22 17:17:24 +00:00
rillig
0ad5a70976
lint: prevent undefined behavior for signed '<<'
...
Found by manual code inspection, verified by MKSANITIZER=yes
USE_SANITIZER=undefined.
2023-01-22 16:05:08 +00:00
rillig
a695cd72f6
lint: add test for floating constant overflow
2023-01-21 17:48:29 +00:00
rillig
798c690d94
lint: add support for C11 '_Atomic' as atomic-type-specifier
...
Following the C11 grammar, the keyword '_Atomic' needs to be a separate
syntactic category, to avoid further conflicts in the grammar.
The two newly added conflicts in the grammar would come into play when
mixing traditional C with C11, in a type name without an implicit 'int'.
If the type '_Atomic(int)*' were parsed as '_Atomic int(int)*', the
trailing '*' would be a syntax error.
2023-01-21 13:48:40 +00:00
rillig
e104b7676c
lint: add support for the C11 type qualifier '_Atomic'
...
That keyword can be used as a type specifier as well, support for that
will be added later.
2023-01-21 13:07:21 +00:00
rillig
149d92727c
tests/lint: test _Atomic, added in C11
2023-01-21 11:57:03 +00:00
rillig
5db76b35c9
lint: fix null pointer dereference on invalid argument to __typeof__
2023-01-21 08:04:43 +00:00
rillig
d67dd6957e
tests/make: rename files that are not test cases
2023-01-19 23:26:14 +00:00
rillig
f523563840
tests/lint: fix typo in comment
2023-01-16 00:37:59 +00:00
rillig
66827794fe
tests/lint: add basic tests for lint (not lint1 or lint2)
2023-01-15 23:18:05 +00:00
rillig
8e78cfd5a6
tests/lint: document conversion from void pointer
2023-01-15 14:00:09 +00:00
rillig
687f4c966a
tests/lint: fix test for sizeof with variable-length array
2023-01-15 13:55:06 +00:00
rillig
f0df5ddf92
tests/lint: add more tests for sizeof
2023-01-15 13:30:04 +00:00
rillig
7997ddce85
tests/lint: add test for parsing sizeof expressions
2023-01-15 00:53:19 +00:00
rillig
a5ae950d72
tests/lint: add more tests for array/enum mismatch
2023-01-14 11:15:07 +00:00
rillig
0f2ef2d80b
lint: rename lint2 functions to be more expressive
2023-01-14 08:48:18 +00:00
rillig
872114d0db
lint: do not report usual arithmetic conversions for constants
2023-01-08 18:37:12 +00:00
rillig
12c5dc767e
lint/tests: test query for usual arithmetic conversions
2023-01-08 18:21:00 +00:00
rillig
8c46ae662d
lint: recognize enum constant named 'max' as a count of values
...
Seen in external/bsd/mdocml/dist/mdoc.h(50).
2023-01-08 15:22:33 +00:00
rillig
e39cd4feb0
tests/lint: add more tests for enum/array mismatch
2023-01-08 15:18:02 +00:00
rillig
a89fe711df
tests/lint: remove obsolete comments
...
The handling of initializers was completely rewritten in init.c 1.228
from 2021-12-21.
2023-01-04 06:04:07 +00:00