#
1.228 |
|
12-May-2024 |
rillig |
lint: add wrapper for <ctype.h> functions, for strict bool mode
When using the Clang preprocessor (with MKLLVM=yes), the preprocessor output does not indicate which tokens come from a system header and which tokens come from the user code. Lint's strict bool mode relies on this information to treat the character classification functions from <ctype.h> as if their return type were bool instead of int.
These wrapper functions are only used when their argument is indeed a 'char', but not when the argument might be 'EOF or representable as an unsigned char', such as when reading a byte from the input.
|
#
1.227 |
|
12-May-2024 |
rillig |
lint: don't call memcpy with null pointer
Even copying 0 bytes from a null pointer invokes undefined behavior.
|
#
1.226 |
|
12-May-2024 |
rillig |
lint: move code for parsing balanced token sequences to lex.c
To access yytext from lex.c, the lexer needs to be in %pointer mode, which was specified in IEEE Std 1003.1, 2004 Edition and thus should be old enough to be available on platforms other than NetBSD, for use in tools/lint1 where lint1 is built before yacc and lex.
|
#
1.225 |
|
09-May-2024 |
rillig |
lint: in C23 mode, support the nullptr constant
|
#
1.224 |
|
07-May-2024 |
rillig |
lint: in C23 mode, support the keywords 'bool', 'false' and 'true'
|
#
1.223 |
|
29-Mar-2024 |
rillig |
lint: clean up
|
#
1.222 |
|
03-Mar-2024 |
rillig |
lint: clean up string parsing and snprintb check
|
#
1.221 |
|
02-Mar-2024 |
rillig |
lint: remove custom wrappers around <ctype.h> functions
|
#
1.220 |
|
01-Mar-2024 |
rillig |
lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character, not the current iterator position.
No binary change.
|
#
1.219 |
|
01-Mar-2024 |
rillig |
lint: fix type error in strict bool mode (since yesterday)
|
#
1.218 |
|
29-Feb-2024 |
rillig |
lint1: remove redundant type table for integer constant suffixes
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.225 |
|
09-May-2024 |
rillig |
lint: in C23 mode, support the nullptr constant
|
#
1.224 |
|
07-May-2024 |
rillig |
lint: in C23 mode, support the keywords 'bool', 'false' and 'true'
|
#
1.223 |
|
29-Mar-2024 |
rillig |
lint: clean up
|
#
1.222 |
|
03-Mar-2024 |
rillig |
lint: clean up string parsing and snprintb check
|
#
1.221 |
|
02-Mar-2024 |
rillig |
lint: remove custom wrappers around <ctype.h> functions
|
#
1.220 |
|
01-Mar-2024 |
rillig |
lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character, not the current iterator position.
No binary change.
|
#
1.219 |
|
01-Mar-2024 |
rillig |
lint: fix type error in strict bool mode (since yesterday)
|
#
1.218 |
|
29-Feb-2024 |
rillig |
lint1: remove redundant type table for integer constant suffixes
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.223 |
|
29-Mar-2024 |
rillig |
lint: clean up
|
#
1.222 |
|
03-Mar-2024 |
rillig |
lint: clean up string parsing and snprintb check
|
#
1.221 |
|
02-Mar-2024 |
rillig |
lint: remove custom wrappers around <ctype.h> functions
|
#
1.220 |
|
01-Mar-2024 |
rillig |
lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character, not the current iterator position.
No binary change.
|
#
1.219 |
|
01-Mar-2024 |
rillig |
lint: fix type error in strict bool mode (since yesterday)
|
#
1.218 |
|
29-Feb-2024 |
rillig |
lint1: remove redundant type table for integer constant suffixes
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.222 |
|
03-Mar-2024 |
rillig |
lint: clean up string parsing and snprintb check
|
#
1.221 |
|
02-Mar-2024 |
rillig |
lint: remove custom wrappers around <ctype.h> functions
|
#
1.220 |
|
01-Mar-2024 |
rillig |
lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character, not the current iterator position.
No binary change.
|
#
1.219 |
|
01-Mar-2024 |
rillig |
lint: fix type error in strict bool mode (since yesterday)
|
#
1.218 |
|
29-Feb-2024 |
rillig |
lint1: remove redundant type table for integer constant suffixes
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.220 |
|
01-Mar-2024 |
rillig |
lint: fix misleading initializer for string iterator
The field 'start' marks the start of the previous matching character, not the current iterator position.
No binary change.
|
#
1.219 |
|
01-Mar-2024 |
rillig |
lint: fix type error in strict bool mode (since yesterday)
|
#
1.218 |
|
29-Feb-2024 |
rillig |
lint1: remove redundant type table for integer constant suffixes
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.217 |
|
08-Feb-2024 |
rillig |
lint: clean up variable names, parameter order, comments
No functional change.
|
#
1.216 |
|
08-Feb-2024 |
rillig |
lint: clean up redundant braces
No functional change.
|
#
1.215 |
|
07-Feb-2024 |
rillig |
lint: use consistent variable names, reduce code for reading a byte
No functional change.
|
#
1.214 |
|
07-Feb-2024 |
rillig |
lint: unify rules for determining the type of an integer constant
Previously, in traditional C mode, large decimal numbers were treated as unsigned, which disagreed with the book from 1978.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.213 |
|
03-Feb-2024 |
rillig |
lint: warn about short octal escape followed by '8' or '9'
These mistakes is typically found in snprintb format directives but is probably a typo everywhere else as well.
|
#
1.212 |
|
03-Feb-2024 |
rillig |
lint: keep strings in their source representation
This allows further analysis depending on whether individual characters are escaped as octal, hexadecimal or not at all.
|
#
1.211 |
|
03-Feb-2024 |
rillig |
lint: allow hexadecimal character escapes up to UINT_MAX
Previously, any value larger than INT_MAX was regarded as negative and thus terminated the loop around get_escaped_char.
|
#
1.210 |
|
03-Feb-2024 |
rillig |
lint: clean up comments, reduce scope of variables
|
#
1.209 |
|
03-Feb-2024 |
rillig |
lint: remove unused code for converting multibyte character sequences
|
#
1.208 |
|
03-Feb-2024 |
rillig |
lint: allow larger numbers in escapes for wide characters and strings
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.207 |
|
02-Feb-2024 |
rillig |
lint: make newline in a string literal an error in C90 and later
|
#
1.206 |
|
01-Feb-2024 |
rillig |
lint: reuse buffer editing code across lint1
Fix cat_strings to update the capacity of the buffer, to prevent quadratic runtime when concatenating string literals.
|
#
1.205 |
|
01-Feb-2024 |
rillig |
lint: use standard buffer for storing string values
No functional change.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.204 |
|
29-Jan-2024 |
rillig |
lint: do not remember content of wide string literals
The plain char literals are needed for checking printf/scanf format strings; lint has no similar check for wide strings. These format strings are checked by modern compilers, making this check less relevant.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.203 |
|
27-Jan-2024 |
rillig |
lint: fix type of large integer constants
|
#
1.202 |
|
27-Jan-2024 |
rillig |
lint: split determining the type of an integer constant
No functional change.
|
#
1.201 |
|
27-Jan-2024 |
rillig |
lint: extract signedness detection from lexing an integer constant
An integer constant that is signed in traditional C but unsigned since C90 is an edge case that should not clutter the main code of determining the resulting type of the constant.
The code for lexing an integer constant doesn't implement the C99 rules yet, which convert a constant to the 'long long' types if the 'long' types don't suffice.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.200 |
|
23-Jan-2024 |
rillig |
lint: rename symt_t to symbol_kind
It was confusing to have two kinds of "symbol type" (s_type and s_symt), so rename all related identifiers to be more distinctive.
No functional change.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.199 |
|
19-Jan-2024 |
rillig |
lint: allow '\e' only in GCC mode
|
#
1.198 |
|
19-Jan-2024 |
christos |
add \e
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.197 |
|
07-Jan-2024 |
rillig |
lint: allow querying for invisible characters in literals and constants
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.196 |
|
03-Dec-2023 |
rillig |
lint: in declarations, replace tab with space
Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense.
No functional change.
|
#
1.195 |
|
03-Dec-2023 |
rillig |
lint: re-wrap comments
No functional change.
|
#
1.194 |
|
03-Dec-2023 |
rillig |
lint: indent statement continuations consistently
No binary change.
|
#
1.193 |
|
02-Dec-2023 |
rillig |
lint: rename NOSCL to NO_SCL
For symmetry with NO_TSPEC. No functional change.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-0-RC1 netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.192 |
|
26-Aug-2023 |
rillig |
lint: make diagnostics about ANSI C more international
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.191 |
|
12-Aug-2023 |
rillig |
lint: clean up lexing of preprocessing lines
The relation between 'c' and 'cp' was tricky to follow.
No functional change.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.190 |
|
01-Aug-2023 |
rillig |
lint: improve debug logging for declarators
|
#
1.189 |
|
30-Jul-2023 |
rillig |
lint: in debug mode, default to indenting the debug log
Only the 'parsing' lines are not indented, as line breaks are independent from the structure of the code.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.188 |
|
15-Jul-2023 |
rillig |
lint: add detailed logging for finding memory allocation bugs
|
#
1.187 |
|
15-Jul-2023 |
rillig |
lint: add debug logging for memory management and the symbol table
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.186 |
|
14-Jul-2023 |
rillig |
lint: document which keywords are available in which language levels
|
#
1.185 |
|
13-Jul-2023 |
rillig |
lint: use separate types for parsing pointer types and type qualifiers
The documentation of the previous 'qual_ptr_t' was misleading, as that type was used for other type qualifier lists as well, even if these were not related to pointer types.
|
#
1.184 |
|
13-Jul-2023 |
rillig |
lint: in C23 mode, recognize the keyword 'thread_local'
|
#
1.183 |
|
13-Jul-2023 |
rillig |
lint: _Thread_local is a storage class, not a type qualifier
|
#
1.182 |
|
13-Jul-2023 |
rillig |
lint: indent copyright lines consistently
|
#
1.181 |
|
13-Jul-2023 |
rillig |
lint: clean up reading lint comments
|
#
1.180 |
|
13-Jul-2023 |
rillig |
lint: reduce code size for handling lint comments
|
#
1.179 |
|
13-Jul-2023 |
rillig |
lint: clean up code related to lint comments
Remove type information from variable names, as the word 'flag' did not indicate that the variables were negated.
Remove contradicting comments. Suppressing a warning for 'this line', 'this and the following line' and 'this statement or declaration' cannot all be accurate at the same time.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.178 |
|
12-Jul-2023 |
rillig |
lint: reduce runtime relocations
|
#
1.177 |
|
12-Jul-2023 |
rillig |
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.
|
#
1.176 |
|
12-Jul-2023 |
rillig |
lint: don't treat 'inline' as a storage class
The additional conflict in the grammar is in the same place as the other conflicts, as T_SCLASS and T_FUNCTION_SPECIFIER are now separate tokens.
No functional change.
|
#
1.175 |
|
12-Jul-2023 |
rillig |
lint: condense keyword table
This prepares for modelling 'inline' not as a storage class, but more correctly as a function specifier.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.174 |
|
10-Jul-2023 |
rillig |
lint: add debug logging for symbol kinds in the parser
An identifier can refer to a variable, type, member, tag or label. Switching between these namespaces is tightly coupled with the evaluation order of the grammar rules.
|
#
1.173 |
|
10-Jul-2023 |
rillig |
lint: clean up wchar_t and hash tables
|
#
1.172 |
|
09-Jul-2023 |
rillig |
lint: miscellaneous cleanup
|
#
1.171 |
|
09-Jul-2023 |
rillig |
lint: clean up wording in diagnostics
Use the term 'parameter' as defined in C99 3.15.
|
#
1.170 |
|
09-Jul-2023 |
rillig |
lint: clean up the wording of a few diagnostics
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.169 |
|
08-Jul-2023 |
rillig |
lint: fix handling of 'long double' in cross-compiled mode
When lint is compiled on x86-64 (where 'long double' has a 64-bit mantissa) and targets arm (where 'long double' has a 53-bit mantissa), warn if a constant cannot fit in the 'long double' of the target platform, not of the host platform.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.168 |
|
03-Jul-2023 |
rillig |
lint: clean up redundant casts
|
#
1.167 |
|
03-Jul-2023 |
rillig |
lint: rename uppercase QUAD to LLONG
No binary change.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.166 |
|
02-Jul-2023 |
rillig |
lint: rename 'quad' to 'signed int' or 'unsigned int'
No functional change.
|
#
1.165 |
|
02-Jul-2023 |
rillig |
lint: extend debug logging for declaration levels
Indent the debug logging according to the declaration level.
Since there are a few cases where the enclosing declaration levels are modified, log the whole declaration level stack whenever a level begins or ends.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.164 |
|
30-Jun-2023 |
rillig |
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.
|
#
1.163 |
|
30-Jun-2023 |
rillig |
lint: replace macro for unique identifiers with function
No functional change.
|
#
1.162 |
|
29-Jun-2023 |
rillig |
lint: clean up member names of declaration levels
No functional change outside debug mode.
|
#
1.161 |
|
24-Jun-2023 |
rillig |
lint: add query for comparing 'char' with plain integers
|
#
1.160 |
|
09-Jun-2023 |
rillig |
lint: miscellaneous clean-ups
No binary change, except for line numbers in assertions.
|
#
1.159 |
|
09-Jun-2023 |
rillig |
lint: indent local variables consistently
No binary change.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.158 |
|
11-Apr-2023 |
rillig |
lint: don't wrongly warn about overflow in complex constants
Seen in lib/libm.
|
#
1.157 |
|
07-Apr-2023 |
rillig |
lint: reduce clutter in parsing preprocessor lines
No functional change.
|
#
1.156 |
|
05-Apr-2023 |
rillig |
lint: fix duplicate warning when parsing big float constants
|
#
1.155 |
|
31-Mar-2023 |
rillig |
lint: allow querying for octal integer constants
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.154 |
|
19-Feb-2023 |
rillig |
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.
|
#
1.153 |
|
19-Feb-2023 |
rillig |
tests/lint: fix and extend tests for C90 migration warning
|
#
1.152 |
|
18-Feb-2023 |
rillig |
lint: remove dead code from lex_floating_constant
Neither traditional C nor C11 allows a trailing 'd' or 'D' on floating point constants. Java does, but lint does not cover Java programs.
|
#
1.151 |
|
18-Feb-2023 |
rillig |
lint: reduce scope of local variables
No functional change.
|
#
1.150 |
|
18-Feb-2023 |
rillig |
lint: use strtold for parsing floating constants
Supported since C99.
|
#
1.149 |
|
18-Feb-2023 |
rillig |
lint: remove compat code for lexing hex floating point literals
Hex floating literals are required by C99.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.148 |
|
02-Feb-2023 |
rillig |
lint: clean up
In symtab_search, most of the conditions were redundant, so remove them.
In read_byte, using CHAR_MASK was conceptually wrong, as that constant is from the target platform while the lexical analysis happens on the host platform. It was unnecessary as well, as a hypothetical host platform with 36-bit chars might encode the characters from the basic source character set as numbers higher than 0x0_0000_00ff. Since lint assumes that both the source character set as well as the execution character set are the same and based on 8-bit bytes, nothing changes.
No functional change.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.147 |
|
29-Jan-2023 |
rillig |
lint: inline an expression, clean up comments
No functional change.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.146 |
|
22-Jan-2023 |
rillig |
lint: clean up the lexer
No functional change.
|
#
1.145 |
|
22-Jan-2023 |
rillig |
lint: prevent undefined behavior for signed '<<'
Found by manual code inspection, verified by MKSANITIZER=yes USE_SANITIZER=undefined.
|
#
1.144 |
|
21-Jan-2023 |
rillig |
lint: use more expressive variable names in lexer
The name 't' could easily be mistaken to mean a tspec_t.
No functional change.
|
#
1.143 |
|
21-Jan-2023 |
rillig |
lint: reduce clutter in lexer
No functional change.
|
#
1.142 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.141 |
|
21-Jan-2023 |
rillig |
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.
|
#
1.140 |
|
21-Jan-2023 |
rillig |
lint: use simpler integers for parsing hex escapes
No functional change.
|
#
1.139 |
|
21-Jan-2023 |
rillig |
lint: use longer variable names, don't count digits in hex escapes
No functional change.
|
#
1.138 |
|
21-Jan-2023 |
rillig |
lint: eliminate forward declaration for get_escaped_char
No functional change.
|
#
1.137 |
|
21-Jan-2023 |
rillig |
lint: extract reading of escaped character constants
No functional change.
|
#
1.136 |
|
21-Jan-2023 |
rillig |
lint: extract parsing character escapes into separate functions
No functional change.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.135 |
|
08-Jan-2023 |
rillig |
lint: document how reading tokens from the input works
Rename inpc to read_byte, to make the name more expressive. Since C99, lint is no longer required to use overly short identifiers.
No functional change.
|
Revision tags: netbsd-10-base
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.134 |
|
01-Oct-2022 |
rillig |
lint: miscellaneous cleanup
No functional change.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.133 |
|
25-Aug-2022 |
rillig |
lint: remove explicit list of known GCC attributes
Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture.
Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms.
To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either.
ok christos@.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.132 |
|
11-Jun-2022 |
rillig |
lint: make definition of type keywords simpler
The only type keyword that is available in more than one variant is 'signed', which can also be written '__signed'. Neither of the type keywords is declared as being specific to GCC, even though __int128_t and __uint128_t actually are non-standard.
No binary change.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.131 |
|
20-May-2022 |
rillig |
lint: use __RCSID in lint mode as well
Since 1995-10-02, lint supports __asm statements and __asm modifiers.
No binary change.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.130 |
|
12-May-2022 |
rillig |
lint: fix support for __alignof__, add support for __alignof
Broken since lex.c 1.129 from yesterday.
|
#
1.129 |
|
11-May-2022 |
christos |
gcc also allows __alignof
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.128 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'sflag'
Mark all places where lint's C90 mode is stricter than its C99 mode.
Most of the situations in which lint produces only warnings instead of errors covered by the "Constraints" sections in the relevant standards. This doesn't prevent a specific compiler from accepting it though.
No functional change.
|
#
1.127 |
|
30-Apr-2022 |
rillig |
lint: inline macro 'tflag'
The definition of the macro tested both allow_trad and allow_c90, but there is only a single mode in which allow_c90 is false, therefore it suffices to test only that.
While double-checking each occurrence of tflag individually, I learned why lint performs lookups of struct members only by name, independently of the struct in which they are declared. See typeok_arrow for details.
No functional change.
|
#
1.126 |
|
30-Apr-2022 |
rillig |
lint: document why in GCC mode, C99 keywords are enabled
|
#
1.125 |
|
30-Apr-2022 |
rillig |
lint: document why C11 keywords are available in C99 mode as well
|
#
1.124 |
|
30-Apr-2022 |
rillig |
lint: move GCC attributes to the bottom of the list
These identifiers have a simpler definition than the other keywords since they do not define when they were introduced.
No functional change.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.123 |
|
16-Apr-2022 |
rillig |
lint: remove null marker from keyword table
No functional change.
|
#
1.122 |
|
16-Apr-2022 |
rillig |
lint: prepare keyword table for C11
The C11 keywords had been listed as being C99 keywords. Instead of initializing the individual fields separately, merge them by specifying the year of the standard in which they appeared.
No binary change, except for line numbers in assertions.
|
#
1.121 |
|
16-Apr-2022 |
rillig |
lint: migrate gflag to allow_gcc
No functional change.
|
#
1.120 |
|
16-Apr-2022 |
rillig |
lint: clean up keyword definitions for the lexer
There is only one specialized keyword that is also a GCC attribute, it's "section". All other keywords passed 0 in that macro argument.
No binary change.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.119 |
|
13-Apr-2022 |
rillig |
lint: fix lint warning on platforms where size_t == unsigned int
lex.c(1451): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
A more thorough fix would be to change the type of block_level from int to size_t, to match mem_block_level, but that change would generate further signedness warnings because the type of sym_t.s_block_level would have to be changed from int to size_t as well, but some symbols have s_block_level == -1, so that's a larger and more error-prone change. Leave that for later.
Whether message 259 makes sense at all in C99 mode is an entirely different question that needs to be answered separately.
No functional change.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.118 |
|
09-Apr-2022 |
rillig |
lint: distinguish between storage class and declaration kind
These types overlap but are not the same.
No functional change.
|
#
1.117 |
|
09-Apr-2022 |
rillig |
lint: disambiguate sym_t.s_value
Having a single variable for 4 different purposes with different types makes the code unnecessarily hard to follow.
No functional change.
|
#
1.116 |
|
09-Apr-2022 |
rillig |
lint: inline member access macros for sym_t
Having the 'u.' explicitly in the code serves as a reminder that these members are only defined under certain conditions.
No functional change.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.115 |
|
02-Apr-2022 |
rillig |
lint: rename dinfo_t.d_next to d_enclosing
The name d_next gave the wrong impression that the declaration infos would be independent of each other, but they are nested.
No functional change.
|
#
1.114 |
|
02-Apr-2022 |
rillig |
lint: add debug logging for the declaration stack
To track down the wrong edge cases in decl_direct_abstract.c.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.113 |
|
13-Mar-2022 |
rillig |
lint: clean up comments, explain assertion in inssym
|
#
1.112 |
|
13-Mar-2022 |
rillig |
lint: use an unsigned counter for temporary variable names
No functional change.
|
#
1.111 |
|
13-Mar-2022 |
rillig |
lint: improve debug logging for the symbol table
Only print the heading for the symbol table level if there is actually a symbol on that level.
Ensure that no symbol with block level -1 is ever in the symbol table (see rmsym).
|
#
1.110 |
|
13-Mar-2022 |
rillig |
lint: fix off-by-one error in symbol table
No functional change since the error was in the "safe" direction.
|
#
1.109 |
|
13-Mar-2022 |
rillig |
lint: rename function 'cleanup' to be more expressive
No functional change.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.108 |
|
01-Mar-2022 |
rillig |
lint: remove redundant assignments to string buffer length
No functional change.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.107 |
|
01-Mar-2022 |
rillig |
lint: add debug logging for symbols and the symbol table
This logging is not active by default, the functions debug_sym and debug_symtab can be called as needed during a debug session.
|
#
1.106 |
|
28-Feb-2022 |
rillig |
lint: constify lexer keywords
No functional change.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.105 |
|
27-Feb-2022 |
rillig |
lint: reorganize lexer functions
Move the keywords table to the top, reduce forward declarations.
No functional change.
|
#
1.104 |
|
27-Feb-2022 |
rillig |
lint: group symbol table functions
No functional change.
|
#
1.103 |
|
27-Feb-2022 |
rillig |
lint: merge duplicate code for handling plain and wide strings
No functional change. As before, the string literals "1" "2" "3" are not concatenated from left to right, instead concatenation starts with "23" and then proceeds to "123".
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.102 |
|
27-Feb-2022 |
rillig |
lint: unabbreviate some fields in sym_t
No functional change.
|
#
1.101 |
|
27-Feb-2022 |
rillig |
lint: encode lifetime of allocated memory in the function names
No functional change.
|
#
1.100 |
|
27-Feb-2022 |
rillig |
lint: clean up memory management for string buffers
There is no reason to duplicate all the work that is already done by the memory allocator.
No functional change.
|
#
1.99 |
|
27-Feb-2022 |
rillig |
lint: clean up memory allocation
No functional change.
|
#
1.98 |
|
26-Feb-2022 |
rillig |
lint: improve debug logging for symbol kinds
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.97 |
|
26-Dec-2021 |
christos |
Add clang's optnone attribute.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.96 |
|
25-Dec-2021 |
rillig |
lint: don't try to trick mathematics by defining ZERO to a nonzero value
No binary change.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.95 |
|
22-Dec-2021 |
rillig |
lint: remove redundant EOF tests in lexer
No functional change.
|
#
1.94 |
|
22-Dec-2021 |
rillig |
lint: clean up lex.c
Rename 'struct kwtab' to 'struct keyword' since a single keyword is not a whole keyword table.
Sync comment for lex_name with reality: sbuf_t no longer contains the hash value.
Remove redundant tests for EOF, as EOF is neither a space nor a digit nor an xdigit.
No functional change.
|
#
1.93 |
|
22-Dec-2021 |
rillig |
lint: remove spaces around bit-field colon
As seen in /usr/share/misc/style.
No binary change.
|
#
1.92 |
|
22-Dec-2021 |
rillig |
lint: rename C89 to C90 in variable names
No binary change.
|
#
1.91 |
|
22-Dec-2021 |
rillig |
lint: use C90 instead of C89 when referring to the C standard
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.90 |
|
15-Dec-2021 |
christos |
Add more attributes
|
#
1.89 |
|
14-Dec-2021 |
christos |
Improve restrict handling.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.88 |
|
27-Nov-2021 |
christos |
Add target attribute
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.87 |
|
16-Nov-2021 |
rillig |
lint: finish renaming of fcon to lex_floating_constant
|
#
1.86 |
|
16-Nov-2021 |
rillig |
lint: rename attron to in_gcc_attribute
No functional change.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.85 |
|
01-Nov-2021 |
rillig |
lint: move all declarations above statements
All code that is used by src/tools is supposed to be compatible with C90.
No functional change.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.84 |
|
18-Sep-2021 |
jmcneill |
use isfinite(3) instead of finite(3) for portability
Fixes tools build on macOS 11.6 arm64 hosts.
|
#
1.83 |
|
17-Sep-2021 |
christos |
Extra commit to fix the actual wrong comment before: Add _Static_assert grammar and keyword
|
#
1.82 |
|
17-Sep-2021 |
christos |
remove the lint kludges
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.81 |
|
05-Sep-2021 |
rillig |
lint: fix lint warnings
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.80 |
|
29-Aug-2021 |
rillig |
lint: allow 'fallthrough' as alternative spelling of FALLTHROUGH
Seen in unbound/lookup3.c.
No change to the documentation since the canonical spelling is still the same.
|
#
1.79 |
|
29-Aug-2021 |
rillig |
lint: accept keyword variant FALL THROUGH as alias to FALLTHROUGH
Seen in archive_string.c, macro WRITE_UC.
No documentation change since the canonical spelling of this keyword stays the same.
|
#
1.78 |
|
28-Aug-2021 |
rillig |
lint: clean up hash functions
No functional change.
|
#
1.77 |
|
28-Aug-2021 |
rillig |
lint: remove unreachable code for parsing integer constants
The largest possible type of an integer constant is 'unsigned long long'. Any larger type can only be expressed using casts.
See also https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html.
|
#
1.76 |
|
28-Aug-2021 |
rillig |
lint: fold constants in hash functions
All platforms supported by lint have sizeof(unsigned int) == 4 and CHAR_BIT == 8. There is no need to encode these expressions in a hash function, they only made the code harder to read.
No functional change.
|
#
1.75 |
|
28-Aug-2021 |
rillig |
lint: replace obsolete strtouq with equivalent strtoull
|
#
1.74 |
|
28-Aug-2021 |
rillig |
lint: fix lexing of character constants
The final value of the character constant must be determined by the target platform, not the host platform.
This allows to run the tests for a target platform with different signedness of characters, by editing targparam.h and t_integration.
Lint is not completely cross-compileable though. 64-bit host platforms can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC does not provide 128-bit integer types.
|
#
1.73 |
|
28-Aug-2021 |
rillig |
lint: explicitly ignore return value of some function calls
This fixes the warning from lint2 that these functions return values which are sometimes ignored.
The remaining calls to fprintf that ignore the return value come from scan.c. Lint does not currently detect the auto-generated portions of that file and the interesting ones since it assumes that scan.c is the main filename, see expr_zalloc_tnode.
No functional change.
|
#
1.72 |
|
28-Aug-2021 |
rillig |
lint: use 'unsigned int' for bit-size of types in convert_integer
There was no need to have two separate magic values (0 and -1) to mean the same.
No functional change.
|
#
1.71 |
|
28-Aug-2021 |
rillig |
lint: un-abbreviate unsigned integer types
No functional change.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.70 |
|
25-Aug-2021 |
rillig |
lint: add __attribute__ regparm
Seen in libexec/ld.elf_so/rtld.h.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.69 |
|
23-Aug-2021 |
rillig |
lint: inline msb
This reduces the binary size on x86_64 by about 500 bytes.
No functional change.
|
#
1.68 |
|
23-Aug-2021 |
rillig |
lint: remove unnecessary width parameter for msb
No functional change.
|
#
1.67 |
|
22-Aug-2021 |
rillig |
lint: use unsigned integers for storing hash values
The computation of the hash values is unchanged, only the resulting value (which is always less than 1009 anyway, see HSHSIZ2) is stored as unsigned as well.
No functional change.
|
#
1.66 |
|
22-Aug-2021 |
rillig |
lint: save some memory
Before lint1.h 1.47 from 2021-01-02, adjacent bit-field struct members shared storage. Restore that using smaller types.
No functional change.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.65 |
|
19-Aug-2021 |
rillig |
lint: change return type of 'msb' from int to bool
No functional change.
|
#
1.64 |
|
19-Aug-2021 |
rillig |
lint: clean up lex_integer_constant
When lexing an integer constant, it does not make sense to check for 'struct', 'void' or other types. Furthermore, the constants were listed in some random-looking order, which made the code hard to read.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.63 |
|
19-Aug-2021 |
christos |
Add returns_nonnull attribute
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.62 |
|
01-Aug-2021 |
rillig |
lint: remove hash value from symbol buffer
Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible.
No functional change.
|
#
1.61 |
|
01-Aug-2021 |
rillig |
lint: merge duplicate code for removing a symbol from the table
No functional change.
|
#
1.60 |
|
01-Aug-2021 |
rillig |
lint: extract duplicate code for modifying the symbol table
No functional change.
|
#
1.59 |
|
01-Aug-2021 |
rillig |
lint: add debug logging for symbol table, clean up debug logging
When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions.
The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05.
|
#
1.58 |
|
31-Jul-2021 |
rillig |
lint: clean up debug logging
The calls to debug_step, unlike printf, don't need a trailing newline.
Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu").
In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07.
No functional change.
|
#
1.57 |
|
31-Jul-2021 |
rillig |
lint: reduce indentation in 'search'
No functional change.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.56 |
|
23-Jul-2021 |
rillig |
lint: write canonical form of keywords
For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc.
Previously, some keywords had leading underscores and some hadn't, this was inconsistent.
No functional change.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.55 |
|
11-Jul-2021 |
rillig |
lint: support __attribute__((hot))
The corresponding attribute 'cold' was already added in cgram.y 1.84 from 2016-12-29.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.54 |
|
10-Jul-2021 |
rillig |
lint: rename y_sb to y_name
That buffer is only used for names of identifiers, so be more specific.
No functional change.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.53 |
|
08-Jul-2021 |
rillig |
lint: remove double negation in comment
No functional change.
|
#
1.52 |
|
08-Jul-2021 |
rillig |
lint: constify keyword in lexer
No functional change.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.51 |
|
06-Jul-2021 |
rillig |
lint: __real__ and __imag__ are GNU extensions
https://gcc.gnu.org/onlinedocs/gcc/Complex.html
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.50 |
|
30-Jun-2021 |
rillig |
lint: inline 'sign' into convert_integer
No functional change.
|
#
1.49 |
|
29-Jun-2021 |
rillig |
lint: rename xsign to convert_integer
The term sign-extend was too specific, the function actually does a broader conversion.
No functional change.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.48 |
|
29-Jun-2021 |
rillig |
lint: clean up lex_character_constant
No functional change.
|
#
1.47 |
|
29-Jun-2021 |
rillig |
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.46 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_unsigned to avoid confusion
The name v_unsigned suggested that the value would be interpreted as unsigned, which was wrong. Whether a value is signed or unsigned is decided by v_tspec instead.
Revert the previous commit for boolen constants since their value is already interpreted as unsigned, and there is no need for any warning about differences between traditional C and ANSI C since the _Bool type has only been added ten years later in C99.
The code for printing a tree node was also confused by this struct member, even with its old name v_ansiu. That code will be fixed in a follow-up commit.
No functional change.
|
#
1.45 |
|
20-Jun-2021 |
rillig |
lint: rename val_t.v_ansiu to v_unsigned
When lint was written in 1995, traditional C was still nearby since C90 had been around for only 5 years. 26 years later, almost all code adheres to C90 or even C99 or C11, therefore "C90 or later" can safely be assumed as the default.
No functional change.
|
#
1.44 |
|
20-Jun-2021 |
rillig |
lint: fix confusing variable name in lex_wide_character_constant
By convention, i is an index, not a count.
No functional change.
|
#
1.43 |
|
20-Jun-2021 |
rillig |
lint: reduce indentation in lexer for character constants
No functional change.
|
#
1.42 |
|
20-Jun-2021 |
rillig |
lint: fix check for empty wide character constant
This bug got almost 26 years old, it was already there at the initial commit in 1995.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.41 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop on unfinished comment at EOF
Found using afl.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.40 |
|
19-Jun-2021 |
rillig |
lint: fix endless loop when scanning string or character literals
If the code contains an unfinished string or character literal at the EOF, the lexer got into an endless loop. Curiously, inpc() returned 0 in such a case instead of the common EOF.
Found by making lint1 with CC=afl-gcc and then running:
afl-fuzz \ -m 200 \ -i in_dir \ -o lint1 \ $src/usr.bin/xlint/lint1/lint1 @@ /dev/null
|
#
1.39 |
|
19-Jun-2021 |
rillig |
lint: revert fix for endless loop in lexer for string literals
String literals may contain null bytes, and these must be passed further on.
This reintroduces the endless loop in the lexer, but that must be fixed in another way that doesn't destroy the error handling.
|
#
1.38 |
|
18-Jun-2021 |
rillig |
lint: fix hang on unfinished string literal at end-of-file
The input file that triggered this bug was:
a"b"c"d
Found using afl.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.37 |
|
15-Jun-2021 |
rillig |
lint: replace array access with function calls
First and foremost, the test d_c99_complex_split accessed the array qlmasks out-of-bounds, with an index of 128 for the type 'double _Complex'. This invoked undefined behavior since the maximum allowed index was 64.
Replacing the raw array accesses with function calls allows for bounds checks to catch these errors early.
Determining the value bits for a 'double _Complex' does not make sense at all since it is not an integer type. This means that lint didn't handle these types correctly for several years. Support for int128_t has been added in inittyp.c 1.12 from 2018-09-07, support for _Complex has been added in inittyp.c 1.9 from 2008-04-26.
Determining the value bits for an int128_t would make sense, but the unit tests don't contain examples for this type since at the moment all unit tests must produce the same results on 32-bit and 64-bit platforms, and the 32-bit platforms don't support int128_t.
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.36 |
|
03-May-2021 |
rillig |
lint: undefine macros for defining keywords after use
No functional change.
|
#
1.35 |
|
03-May-2021 |
rillig |
lint: remove redundancy when defining classic keywords
No functional change.
|
#
1.34 |
|
03-May-2021 |
rillig |
lint: reduce redundancy when defining GCC attributes
This macro would have prevented the unintended inconsistency in the attribute 'pcs' (for ARM).
No functional change. The generated code is the same, except for the line numbers in lint_assert.
|
#
1.33 |
|
03-May-2021 |
rillig |
lint: allow variables to be named 'pcs'
|
#
1.32 |
|
03-May-2021 |
rillig |
lint: fix compiler warning about signedness mismatch
No functional change.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.31 |
|
01-May-2021 |
christos |
put back nonnull. I meant to just sort it.
|
#
1.30 |
|
30-Apr-2021 |
christos |
- add nonstring attribute - allow attributes after labels (for unused) XXX: split the attributes into function, variable, etc attributes so that we don't accept all attributes in all places (only where they make sense)
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.29 |
|
20-Apr-2021 |
christos |
Add common attribute
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.28 |
|
18-Apr-2021 |
rillig |
lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage class AUTO. Instead, its storage class is either EXTERN or STATIC.
While removing the temporary objects from the symbol table had prevented the assertion, it did not properly fix the underlying problem, which was that since C99 the initializers can contain references to unnamed objects that are created on-the-fly. For C90 it was correct to always use AUTO as the storage class of a temporary symbol.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.27 |
|
12-Apr-2021 |
christos |
Add attribute fallthrough
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.26 |
|
09-Apr-2021 |
rillig |
lint: clean up handling of preprocessing output lines
No functional change.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.25 |
|
08-Apr-2021 |
rillig |
lint: in code from included files, print stack trace
Previously, the standard NetBSD build generated several lint warnings in lhash.h from OpenSSL, without providing any hint as to which file actually included that header. In cases like these, lint now interprets the line number information in the preprocessor output from GCC to reconstruct the exact include path to the file in question.
The program check-expect.lua had to be rewritten almost completely since it assumed that all diagnostics would come from the main file. In all existing tests, this was true, but these tests did not cover all cases that occurred in practice. Now it records the complete location of the diagnostic instead of just the line number.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.24 |
|
06-Apr-2021 |
rillig |
lint: sync comment with reality after renaming several functions
No functional change.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.23 |
|
02-Apr-2021 |
rillig |
lint: reduce memory usage
No functional change.
|
#
1.22 |
|
02-Apr-2021 |
rillig |
lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.21 |
|
28-Mar-2021 |
rillig |
lint: sprinkle const on function declarations
No functional change.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.20 |
|
27-Mar-2021 |
rillig |
lint: rename LERROR to INTERNAL_ERROR
The '#ifndef' in tyname.c is meant to distinguish between lint1 and lint2, it is not meant to be defined from anywhere outside the lint code itself.
No functional change.
|
#
1.19 |
|
27-Mar-2021 |
rillig |
lint: rename filename management functions
No functional change.
|
#
1.18 |
|
27-Mar-2021 |
rillig |
lint: remove space between 'sizeof ('
No functional change.
|
#
1.17 |
|
26-Mar-2021 |
rillig |
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.16 |
|
23-Mar-2021 |
christos |
Add _Alignas()
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.15 |
|
21-Mar-2021 |
rillig |
lint: rename functions for handling control statements
No functional change.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.14 |
|
20-Mar-2021 |
rillig |
lint: make lint's own code pass the strict bool mode
No functional change.
|
#
1.13 |
|
20-Mar-2021 |
rillig |
lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the correct type. The flags in kwtab are of type bool and were initialized with an int, for brevity. Keep the brevity and do the conversion from int to bool in a macro.
By defining several macros for the different kinds of keywords, reduce the clutter of having 2 additional zeroes per line. The macros also remove the redundancy and thereby the possible inconsistency of filling the wrong fields since these depend on the token type.
No functional change. The only change to the binary is due to the changed line numbers in the calls to lint_assert.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|
#
1.12 |
|
17-Mar-2021 |
rillig |
lint: rename 'blklev' to 'block_level'
No functional change.
|
#
1.11 |
|
01-Mar-2021 |
rillig |
lint: only warn once about integer constant overflow on 32-bit
Previously, the test msg_056.c warned twice about the integer literal, but only on 32-bit platforms. On 64-bit platforms, there was only a single warning since the integer constant was converted to type __uint128_t, and this prevented the second warning. On 32-bit targets, there is no __uint128_t though.
Fixes part of PR bin/55976.
|
#
1.10 |
|
28-Feb-2021 |
rillig |
lint: rename members and access macros of the basic types
Having the measurement unit in the variable name prevents accidental confusion between bits and bytes, especially since usually the word 'size' means the size in bytes, while 'width' means the size in bits, at least for integer types.
No functional change.
|
#
1.9 |
|
22-Feb-2021 |
rillig |
lint: change spelling of initialisation to initialization
That's the wording from the ISO C99 standard.
|
#
1.8 |
|
20-Feb-2021 |
rillig |
lint: make parsing of GCC line directives stricter
The previous code accepted '# 123 "file.c" 23' as specifying a system header, just because that number ends with '3'. The original intention was to compare the complete word, not its suffix. Fix that.
No practical change since the only flags that are used by GCC are all single-digit.
|
#
1.7 |
|
24-Jan-2021 |
rillig |
lint: fix build on Cygwin
Cygwin does not conform to C99, which says that MB_CUR_MAX has type size_t.
Instead, Cygwin defines it as type int. This leads to compile errors because comparing signed with unsigned expressions is surprising in C.
|
#
1.6 |
|
24-Jan-2021 |
rillig |
lint: expand abbreviations in lexer function names
No functional change.
|
#
1.5 |
|
24-Jan-2021 |
rillig |
lint: explain why !finite(x) is not allowed in strict bool mode
|
#
1.4 |
|
24-Jan-2021 |
christos |
fix the build
|
#
1.3 |
|
23-Jan-2021 |
rillig |
lint: apply strict bool mode to lex.c
There are 2 remaining expressions:
In line 244, !(kw->kw_deco & deco) is a bitwise and. This is already allowed for enums, it needs to be allowed for arbitrary integer expressions as well. This covers the many places where plain integers are used for bit fields, together with #define. This pattern is not as typesafe as using enums, still it is common practice.
In line 769, the expression !finite(f) is a legitimate use of a function that has return type int for traditional reasons. It's the same as for ferror.
There are several other functions like unlink, open or strcmp that have return type int as well, but with a different meaning. It is not yet clear what the best way is to handle these different meanings. Having to write finite(f) == 0 in strict bool mode doesn't look idiomatic, on the other hand, !strcmp(s1, s2) is exactly the pattern that strict bool mode wants to avoid.
|
#
1.2 |
|
23-Jan-2021 |
rillig |
lint: clean up comments and variable names in lex.c
|
#
1.1 |
|
23-Jan-2021 |
rillig |
lint: move lexer code from scan.l to lex.c
Previously, the generated scan.c was not included when running "make lint". Similarly, cgram.c is still not included.
|