History log of /src/usr.bin/xlint/lint1/main1.c |
Revision | | Date | Author | Comments |
1.84 |
| 24-Sep-2024 |
rillig | lint: exclude the GCC builtins from debug logging
Their source code is parsed for simplicity, and since the text is fixed, there is nothing surprising to be expected there. Instead, start debugging when the actual code begins.
|
1.83 |
| 12-May-2024 |
rillig | branches: 1.83.2; lint: remove unused flag '-u' from lint1
This flag is completely handled by lint2.
|
1.82 |
| 03-Feb-2024 |
rillig | lint: remove excessive empty lines
|
1.81 |
| 03-Feb-2024 |
rillig | lint: clean up comments, reduce scope of variables
|
1.80 |
| 02-Feb-2024 |
rillig | lint: use the locale for interpreting wide character strings
|
1.79 |
| 21-Jan-2024 |
rillig | lint: create .ln output file even when queries are enabled
This allows to configure lint flags in mk.conf globally for a whole NetBSD build. Previously, this would have made the build fail due to missing .ln files.
The previous use case of rerunning lint with or without queries is easy enough to achieve by doing a 'make clean', in the same way as for lint warnings.
|
1.78 |
| 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.77 |
| 29-Jul-2023 |
rillig | lint1: remove option -m
The list of lint messages is only needed for generating the manual page lint.7. Since 2022-07-06, that list is extracted from the source code instead of compiling and then running lint1.
|
1.76 |
| 29-Jul-2023 |
rillig | lint: condense code for ending a function
No functional change.
|
1.75 |
| 29-Jul-2023 |
rillig | lint: use standard function attribute for noreturn functions
|
1.74 |
| 13-Jul-2023 |
rillig | lint: indent copyright lines consistently
|
1.73 |
| 08-Jul-2023 |
rillig | lint: use consistent conditional compilation guards
|
1.72 |
| 07-Jul-2023 |
rillig | lint: only skip 'unused' warnings after errors, not other warnings
Previously, in -w mode, any warning suppressed further 'unused' warnings, even though there was no need to do that. This can be seen in the test gcc_attribute_var.c, where only the last unused variable from a function was marked as unused, the others slipped through.
Fixed by counting the errors and the warnings separately and only combining them if actually desired.
|
1.71 |
| 03-Jul-2023 |
rillig | lint: sync usage messages with reality
|
1.70 |
| 03-Jul-2023 |
rillig | lint: invert the -u, -v and -z flags
Now they behave the same as in the manual page.
No functional change.
|
1.69 |
| 03-Jul-2023 |
rillig | lint: remove redundant comments for command line flags
|
1.68 |
| 03-Jul-2023 |
rillig | lint: fix C11 mode to not allow C23 features (since yesterday)
|
1.67 |
| 02-Jul-2023 |
rillig | lint: add initial support for C23
Required by xsrc/external/mit/MesaLib.old, brw_eu_validate.c, which initializes a struct using empty braces: 'return (struct string){};'.
|
1.66 |
| 13-Jan-2023 |
rillig | lint: remove custom memory allocator
Besides adding complexity, the custom memory allocator didn't invalidate freed memory, which made it harder to find possible use-after-free bugs.
|
1.65 |
| 05-Jul-2022 |
rillig | lint: add additional queries that are not enabled by default
In the last 18 months, several lint warnings have been made adjusted to allow common usage patterns. For example, lint no longer warns about a constant condition in the statement 'do { ... } while (false)' (message 161), as this pattern is well-known in statement-like macros, making it unlikely that the 'false' is a mistake. Another example is casts between unequal pointer types (message 247) for a few well-known patterns that are unlikely to be bugs.
Occasionally, it is useful to query the code for patterns or events that would not justify a warning. These patterns are modeled as predefined queries that can be selected individually, in addition to and independently of the existing warnings and errors.
New queries can be added as needed, in the same way as new warnings. Queries that are deemed no longer used can be deactivated in the same way as warnings that are no longer used.
As long as none of the queries is enabled, they produce a minimal overhead of querying a single global variable. Computations that are more expensive than a few machine instructions should be guarded by any_query_enabled.
https://mail-index.netbsd.org/source-changes-d/2022/06/28/msg013716.html
ok christos@
|
1.64 |
| 01-Jul-2022 |
rillig | lint: move error handling code from main1.c to err.c
No functional change.
|
1.63 |
| 30-May-2022 |
rillig | lint: report proper file name in assertion failures
When given the (obviously malformed) translation unit 'f=({;};}', lint runs into an assertion failure. It reported this as occurring near ':1'. This location was missing a filename since the input didn't contain a GCC line number directive such as '# 2 "input.c"'. In GCC mode, the GCC builtins are loaded first, in which case the reported location was ':9'.
Fix this by providing proper location information, even for input that does not come from the GCC C preprocessor.
|
1.62 |
| 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.61 |
| 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.60 |
| 16-Apr-2022 |
rillig | lint: model C language levels in a future-compatible way
The options -t, -s and -S are confusing because they are used inconsistently. The option -S enables C99 features, but when using it instead of -s, it also doesn't enable all checks required by C90 and later. Prepare fixing of these inconsistencies by replacing the flag variables with language levels that can be extended in a straight-forward way as new C standards arrive.
| option | allow_trad | allow_c90 | allow_c99 | allow_c11 | |--------|------------|-----------|-----------|-----------| | -t | x | - | - | - | | (none) | x | x | - | - | | -s | - | x | - | - | | -S | - | x | x | - | | -Ac11 | - | x | x | x |
Each usage of the old flag variables will be inspected and migrated individually, to clean up the subtle variations in the conditions and to provide a simpler model.
When lint was created in 1995, its focus was migrating traditional C code to C90 code. Lint does not help in migrating from C90 to C99 or from C99 to C11 since there are only few silent changes, and simply because nobody took the time to implement these migration aids. If necessary, such migration modes could be added separately.
There is a small functional change: when the option -s is combined with either -S or -Ac11, lint now only keeps the last of these options. Previously, these options could be combined, leading to a mixture of language levels, halfway between C90, C99 and C11. Especially combining traditional C with C11 doesn't make sense, but xlint currently allows it.
The 3 tests that accidentally specified multiple language levels have been adjusted to a single language level.
|
1.59 |
| 27-Feb-2022 |
rillig | lint: C99 has been released, so refer to it by its proper name
|
1.58 |
| 17-Dec-2021 |
rillig | lint: in GCC mode, declare alloca and variants
The prototype declarations define the correct parameter types of these functions so that they are no longer subject to the default argument promotions (C11 6.5.2.2p6).
The GCC builtins are only recognized in GCC mode (-g).
|
1.57 |
| 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.56 |
| 17-Aug-2021 |
rillig | lint: extract suppress_messages from main
No functional change.
|
1.55 |
| 17-Aug-2021 |
rillig | lint: sync usage message with reality
|
1.54 |
| 17-Aug-2021 |
rillig | lint: move GCC builtins into gcc_builtins
No functional change.
|
1.53 |
| 01-Aug-2021 |
rillig | lint: merge duplicate debugging code
The functions 'debug_node' and 'display_expression' were similar enough to be merged.
Migrate debug_node to use the existing debug logging functions.
Remove the now unused option 'd' from the options string.
|
1.52 |
| 01-Aug-2021 |
rillig | lint: remove option -d, clean up debug logging
The command line option -d was not used by /usr/bin/lint, and it only triggered a handful of debug messages. Move this debug logging over to the compile-time -DDEBUG setting.
Move display_expression further up to avoid the forward declaration.
|
1.51 |
| 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.50 |
| 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.49 |
| 04-Jul-2021 |
rillig | lint: sync stdout and stderr when compiled in debug mode
If lint is compiled with -DDEBUG, its debug output goes to stdout, no matter whether the option -d is given or not.
|
1.48 |
| 03-Jul-2021 |
rillig | lint: do not define 'long double' GCC builtins for traditional C
|
1.47 |
| 03-Jul-2021 |
rillig | lint: make stdout unbuffered in debug mode
Some debug log messages are on stdout, others on stderr. Make sure that they occur in the correct order, even when the output is redirected.
|
1.46 |
| 27-Jun-2021 |
rillig | lint: fix option -Ac11, add test for _Generic
Previously, selecting the option -Ac11 allowed features from C11 but at the same time prohibited 'long long', which was added in C99. This was caused by the option -s, which is interpreted as "allow features from C90, but no later".
The test for _Generic, which has been added in C11, demonstrates that the current implementation is broken. Lint currently thinks that the return type of a _Generic selection is the type of the expression, but it really is the type of the selected expression. In the current tests, this is always 'const char *', but C11 does not require that the types of a generic selection are compatible.
|
1.45 |
| 18-Apr-2021 |
rillig | lint: remove WARNS=3, falling back to the default WARNS=5
It's strange that GCC does not warn about the nonliteral format strings in lint1/err.c, lint2/msg.c and lint2/read.c, despite -Wformat=2, but Clang does.
|
1.44 |
| 18-Apr-2021 |
rillig | lint: clean up option parsing
|
1.43 |
| 14-Apr-2021 |
rillig | lint: add option to accept C11 features
The list of available letters for the command line options gets shorter and shorter. Most of the interesting letters are already used for some warning categories. Curiously, -A, -W and -E were all still available.
The option -A nicely matches the intention of the option, which is to allow a certain set of language features. To keep the option available for further extensions, define -Ac11 as the currently only valid option of that kind. This allows straight-forward extension for C17 and future language standards, as well as independent feature-sets. The options -W and -E may someday complement the -A option, using the allow/warn/error categories.
|
1.42 |
| 02-Apr-2021 |
rillig | lint: add parentheses after sizeof, as required by share/misc/style
No functional change.
|
1.41 |
| 28-Mar-2021 |
rillig | lint: only define GCC builtins if -g is given
This removes 7 wrong warnings when running lint in -t mode.
Surprisingly, this added a warning that had not been there before in msg_189.c. This is because check_variable_usage skips the checks when an error occurred before. All diagnostics that happened were warnings, but the -w option treats them as errors, see vwarning.
|
1.40 |
| 27-Mar-2021 |
rillig | lint: rename fnaddreplsrcdir to something less cryptic
No functional change.
|
1.39 |
| 26-Mar-2021 |
rillig | lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'
No functional change.
|
1.38 |
| 20-Mar-2021 |
rillig | lint: remove redundant operator properties table
It's enough to have modtab, which describes the properties of the various operators. There is no need to have a second table imods that holds the same content. Rather make modtab constant as well.
The only possible functional change is that the names of the internal operators 'no-op', '++', '--', 'real', 'imag' and 'case' may appear in diagnostics, where previously lint invoked undefined behavior by passing a null pointer for a '%s' conversion specifier.
|
1.37 |
| 16-Jan-2021 |
rillig | lint: replace integer constant expressions with true and false
LINTFLAGS=-gST make lint, with manual review.
The error messages from lint are all correct, they are not complete though. The return value of a function returning bool may still be compared to the integer 0.
|
1.36 |
| 16-Jan-2021 |
rillig | lint: replace 0 and 1 with false and true, where appropriate
Change in behavior: Passing the option -h exactly 4294967296 times or any multiple thereof is no longer equivalent to passing it never at all, it is now equivalent to passing it once. See main2.c, hflag++ for the actual change.
Other than that, no functional change intended.
A very large portion of the code already conformed to the requirements of the strict bool mode. The only missing thing was using the constant literals false and true instead of 0 and 1. For sure there are some integer literals left that can be converted. For now, all literals that appeared in the form " = 0" or " = 1" have been replaced.
|
1.35 |
| 12-Jan-2021 |
rillig | lint: update usage for lint1 and lint2
(Forgotten in the previous commit.)
|
1.34 |
| 12-Jan-2021 |
rillig | lint: add new check for strict bool mode
In strict bool mode, bool is considered incompatible with all other scalar types, just as in Java, C#, Pascal.
The controlling expressions in if statements, while loops, for loops and the '?:' operator must be of type bool. The logical operators work on bool instead of int, the bitwise operators accept both integer and bool. The arithmetic operators don't accept bool.
Since <stdbool.h> implements bool using C preprocessor macros instead of predefining the identifiers "true" and "false", the integer constants 0 and 1 may be used in all contexts that require a bool expression. Except from these, no implicit conversion between bool and scalar types is allowed.
See usr.bin/tests/xlint/lint1/d_c99_bool_strict.c for more details.
The command line option -T has been chosen because all obvious choices (-b or -B for bool, -s or -S for strict) are already in use. The -T may stand for "types are checked strictly".
The default behavior of lint doesn't change. The strict bool check is purely optional.
An example program for strict bool mode is usr.bin/make, which has been using explicit comparisons such as p != NULL, ch != '\0' or n > 0 in most places for a long time now, even before the refactoring in 2020.
|
1.33 |
| 10-Jan-2021 |
rillig | lint: remove redundant parentheses around return value
|
1.32 |
| 04-Jan-2021 |
rillig | lint: fix typos and other minor stylistic issues
|
1.31 |
| 29-Dec-2020 |
rillig | lint: remove redundant parentheses around return value
|
1.30 |
| 29-Dec-2020 |
rillig | lint: rename functions that had very short names
C99 guarantees that the first 31 characters of an identifier with external linkage are significant. This removes the need to use abbreviations for common words.
|
1.29 |
| 28-Dec-2020 |
rillig | lint: sort includes
|
1.28 |
| 28-Dec-2020 |
rillig | lint1: remove trailing whitespace
|
1.27 |
| 23-Dec-2018 |
christos | yydebug is now available only if YYDEBUG is set.
|
1.26 |
| 24-Dec-2016 |
christos | branches: 1.26.12; 1.26.14; Add -R (source filename remapping) for MKREPRO
|
1.25 |
| 18-Apr-2014 |
christos | branches: 1.25.6; provide a poor man's fmemopen()
|
1.24 |
| 18-Apr-2014 |
christos | don't include fmemopen in tools builds. Since tools does not define _NETBSD_SOURCE, we don't get the fmemopen prototype
|
1.23 |
| 18-Apr-2014 |
christos | builtins only for NetBSD since fmemopen is not portable.
|
1.22 |
| 18-Apr-2014 |
christos | Add some builtins
|
1.21 |
| 19-Apr-2013 |
christos | branches: 1.21.4; Allow linted comments to take an argument that defines which error to suppress.
|
1.20 |
| 27-Mar-2012 |
christos | branches: 1.20.2; more cross lint friendlyness XXX: needs more constants converted double/float
|
1.19 |
| 31-Jul-2008 |
christos | branches: 1.19.2; Add Picky flag; this produces more warnings: 1. long a; int i; a = i * i; suggests casting i to long, so that we gain precision in the multiplication. 2. warns about magnitude comparisons in enums. 3. warns about possible sign extension issues when integer types become widened.
|
1.18 |
| 02-May-2008 |
christos | branches: 1.18.2; Since we cannot guarantee that all machines do ieee math, or that they have the proper math setup deal with SIGFPE directly.
|
1.17 |
| 08-Nov-2006 |
christos | branches: 1.17.16; - add debugging to track nowarns - make /*LINTED*/ take effect on unused functions
|
1.16 |
| 24-Sep-2005 |
perry | in several comments: implizit -> implicit explizit -> explicit
|
1.15 |
| 20-Jun-2004 |
jmc | Completely rework how tools/compat is done. Purge all uses/references to _NETBSD_SOURCE as this makes cross building from older/newer versions of NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to only use POSIX code in all places (or when reasonable test w. configure and provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86 NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
|
1.14 |
| 18-Apr-2003 |
lukem | branches: 1.14.2; clear errno before strto(u)l() if we're going to test it for ERANGE afterwards
|
1.13 |
| 21-Oct-2002 |
christos | support for c99 style and gnu style structure and union named initializers.
|
1.12 |
| 31-Jan-2002 |
tv | Use setprogname() in main().
|
1.11 |
| 29-Jan-2002 |
tv | Remove #include <err.h> (now in lint.h).
|
1.10 |
| 13-Dec-2001 |
augustss | Don't use fd_set to keep track of errors to ignore. Doing so relies on overriding FD_SETSIZE. Not overriding it makes it stomp all over memory (which caused the debug outputs we've seen lately). It used to work, but toolification of lint broke it.
|
1.9 |
| 04-Dec-2001 |
wiz | Replace some misuses of "then" with "than".
|
1.8 |
| 28-May-2001 |
lukem | cleanup (prior to more adding more features): - convert to ANSI KNF - remove trailing whitespace - translate some comments from german into english
code compiles and runs clean, and tested by running "make lint" against xlint source using previous and this lint produces same results.
|
1.7 |
| 24-Feb-2001 |
cgd | fix broken NetBSD RCS id tags
|
1.6 |
| 20-Feb-2001 |
cgd | use getprogname()
|
1.5 |
| 06-Jul-2000 |
christos | add 3 new flags: -m print message list -X <id>[,<id>]... suppress error messages with give ids. -w treat warnings as errors.
|
1.4 |
| 22-Feb-1998 |
christos | WARNSify
|
1.3 |
| 02-Oct-1995 |
jpo | LINTED and CONSTCOND are now valid up to the next end of a global or local declaration/definition/statement. Originally they were valid on the current and next line, which made it hard to suppress warnings in constructs with more then one line.
LONGLONG can now be used to suppress errors or warnings in the next declaration, definition or statement.
|
1.2 |
| 03-Jul-1995 |
cgd | RCS id cleanup
|
1.1 |
| 03-Jul-1995 |
cgd | branches: 1.1.1; Initial revision
|
1.1.1.1 |
| 03-Jul-1995 |
cgd | lint(1) implementation, by Jochen Pohl. named 'xlint' for a similar reason to why 'install' is named 'xinstall'.
|
1.14.2.1 |
| 22-Jun-2004 |
tron | Pull up revision 1.15 (requested by jmc in ticket #527): Completely rework how tools/compat is done. Purge all uses/references to _NETBSD_SOURCE as this makes cross building from older/newer versions of NetBSD harder, not easier (and also makes the resulting tools 'different') Wrap all required code with the inclusion of nbtool_config.h, attempt to only use POSIX code in all places (or when reasonable test w. configure and provide definitions: ala u_int, etc). Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86 NetBSD current (x86 and amd64) and Solaris 9. Fixes PR's: PR#17762 PR#25944
|
1.17.16.1 |
| 18-May-2008 |
yamt | sync with head.
|
1.18.2.1 |
| 18-Sep-2008 |
wrstuden | Sync with wrstuden-revivesa-base-2.
|
1.19.2.2 |
| 22-May-2014 |
yamt | sync with head.
for a reference, the tree before this commit was tagged as yamt-pagecache-tag8.
this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments")
|
1.19.2.1 |
| 17-Apr-2012 |
yamt | sync with head
|
1.20.2.2 |
| 20-Aug-2014 |
tls | Rebase to HEAD as of a few days ago.
|
1.20.2.1 |
| 23-Jun-2013 |
tls | resync from head
|
1.21.4.1 |
| 10-Aug-2014 |
tls | Rebase.
|
1.25.6.1 |
| 07-Jan-2017 |
pgoyette | Sync with HEAD. (Note that most of these changes are simply $NetBSD$ tag issues.)
|
1.26.14.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.26.12.1 |
| 26-Dec-2018 |
pgoyette | Sync with HEAD, resolve a few conflicts
|
1.83.2.1 |
| 02-Aug-2025 |
perseant | Sync with HEAD
|