History log of /netbsd-current/usr.bin/xlint/lint1/lint1.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.227 11-May-2024 rillig

lint: parse but otherwise ignore C23 attributes

The C23 attributes are only parsed before an expression in an expression
statement, as a proof of concept. Other places will follow later.


# 1.226 09-May-2024 rillig

lint: in C23 mode, support the nullptr constant


# 1.225 07-May-2024 rillig

lint: in C23 mode, support the keywords 'bool', 'false' and 'true'


# 1.224 03-May-2024 rillig

lint: measure the alignment in bytes, not bits

While measuring the alignment in bits makes sense when building a struct
type with bit-fields, in all other places it is more confusing than
helpful.

The only visible change is that in debug mode, the format of type sizes
and alignment changed. Since the size of all complete types is a
multiple of a byte (as defined in the C standard), sizes and alignments
are reported in bytes as well. Only while a struct is being built, the
type size may include an additional '+x' for the bits of a bit-field.


# 1.223 01-May-2024 rillig

lint: support _Alignas and __attribute__((__aligned(4)))


# 1.222 31-Mar-2024 rillig

lint: merge function call operators 'CALL' and 'ICALL'


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.226 09-May-2024 rillig

lint: in C23 mode, support the nullptr constant


# 1.225 07-May-2024 rillig

lint: in C23 mode, support the keywords 'bool', 'false' and 'true'


# 1.224 03-May-2024 rillig

lint: measure the alignment in bytes, not bits

While measuring the alignment in bits makes sense when building a struct
type with bit-fields, in all other places it is more confusing than
helpful.

The only visible change is that in debug mode, the format of type sizes
and alignment changed. Since the size of all complete types is a
multiple of a byte (as defined in the C standard), sizes and alignments
are reported in bytes as well. Only while a struct is being built, the
type size may include an additional '+x' for the bits of a bit-field.


# 1.223 01-May-2024 rillig

lint: support _Alignas and __attribute__((__aligned(4)))


# 1.222 31-Mar-2024 rillig

lint: merge function call operators 'CALL' and 'ICALL'


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-3-RELEASE netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.224 03-May-2024 rillig

lint: measure the alignment in bytes, not bits

While measuring the alignment in bits makes sense when building a struct
type with bit-fields, in all other places it is more confusing than
helpful.

The only visible change is that in debug mode, the format of type sizes
and alignment changed. Since the size of all complete types is a
multiple of a byte (as defined in the C standard), sizes and alignments
are reported in bytes as well. Only while a struct is being built, the
type size may include an additional '+x' for the bits of a bit-field.


# 1.223 01-May-2024 rillig

lint: support _Alignas and __attribute__((__aligned(4)))


# 1.222 31-Mar-2024 rillig

lint: merge function call operators 'CALL' and 'ICALL'


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.223 01-May-2024 rillig

lint: support _Alignas and __attribute__((__aligned(4)))


# 1.222 31-Mar-2024 rillig

lint: merge function call operators 'CALL' and 'ICALL'


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.222 31-Mar-2024 rillig

lint: merge function call operators 'CALL' and 'ICALL'


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.221 09-Mar-2024 rillig

lint: inline accessor macros for tnode_t


# 1.220 09-Mar-2024 rillig

lint: inline accessor macros for type_t


# 1.219 09-Mar-2024 rillig

lint: clean up comments, use typedefs


# 1.218 09-Mar-2024 rillig

lint: internally store case label values in order of appearance


# 1.217 09-Mar-2024 rillig

lint: remove unneeded checks for left and right operands


# 1.216 09-Mar-2024 rillig

lint: use fewer struct keywords


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.215 03-Mar-2024 rillig

lint: clean up string parsing and snprintb check


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


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.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.214 05-Feb-2024 rillig

lint: make function call arguments directly accessible

Previously, the arguments of a function call expression were arranged in
a linear tree structure, from right to left. To allow easier access to
the arguments, store them in an array instead.


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.213 03-Feb-2024 rillig

lint: remove excessive empty lines


# 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 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.211 01-Feb-2024 rillig

lint: use standard buffer for storing string values

No functional change.


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.210 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.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.209 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.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.208 11-Jan-2024 rillig

lint: clean up enum constants for designators

In intializers and offsetof, both struct and union members are handled
in the same way, thus there is no need to distinguish them.


# 1.207 09-Jan-2024 rillig

lint: allow complex offsetof(type, member-designator)

Both GCC 11 and Clang 8 accept member-designators that are not
identifiers but designator sequences, such as in 'offsetof(struct stat,
st_atim.tv_sec)', so make lint accept them as well.


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.206 06-Jan-2024 rillig

lint: remove redundant parentheses, braces and comments

Rename the functions for folding constant expressions, to make the
comments redundant.


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.205 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.204 03-Dec-2023 rillig

lint: re-wrap comments

No functional change.


# 1.203 02-Dec-2023 rillig

lint: rename NOSCL to NO_SCL

For symmetry with NO_TSPEC. No functional change.


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-0-RC1 netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.202 14-Sep-2023 rillig

lint: remove preprocessor magic from definition of operators

No binary change.


# 1.201 13-Sep-2023 rillig

lint: prevent invalid memory access when checking an expression

In check_expr_misc, the left and right operands of an expression were
accessed even in the case of CON (constant), STRING (string literal) and
NAME (identifier), which led to invalid values in pointer variables.
These invalid values were not used though, but technically they invoked
undefined behavior.

Precede each access to the operands with a check that the expression
indeed has operands, except in those cases where the operand is known to
have operands by only looking at the code of the current function.


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.200 26-Aug-2023 rillig

lint: make diagnostics about ANSI C more international


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.199 02-Aug-2023 rillig

lint: distinguish between arguments and parameters


# 1.198 01-Aug-2023 rillig

lint: clear global variable 'dcs' after use

Having unnecessarily set members is confusing during debugging.


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.197 29-Jul-2023 rillig

lint: only generate err-msgs.h in debug mode


# 1.196 28-Jul-2023 rillig

lint: extract 'vararg' and 'prototype' flags from global 'dcs'

These flags are only relevant for parameter lists, so add a separate
type for it.

No functional change.


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.195 19-Jul-2023 rillig

lint: work around a possible compiler error on arm and powerpc


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.194 15-Jul-2023 rillig

lint: add detailed logging for finding memory allocation bugs


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.193 14-Jul-2023 rillig

lint: clean up comments, add a test for the '?:' operator


# 1.192 13-Jul-2023 rillig

lint: merge duplicate code for checking duplicate type qualifiers


# 1.191 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.190 13-Jul-2023 rillig

lint: _Thread_local is a storage class, not a type qualifier


# 1.189 13-Jul-2023 rillig

lint: indent copyright lines consistently


# 1.188 13-Jul-2023 rillig

lint: reduce code size for handling lint comments


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.187 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.186 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.185 11-Jul-2023 rillig

lint: update wording in diagnostic for C99


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.184 10-Jul-2023 rillig

lint: merge duplicate code for getting the name of an operator


# 1.183 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.182 09-Jul-2023 rillig

lint: miscellaneous cleanup


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.181 03-Jul-2023 rillig

lint: clean up redundant casts


# 1.180 03-Jul-2023 rillig

lint: rename uppercase QUAD to LLONG

No binary change.


# 1.179 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.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.178 02-Jul-2023 rillig

lint: clean up variable names relating to structure padding


# 1.177 02-Jul-2023 rillig

lint: rename 'quad' to 'signed int' or 'unsigned int'

No functional change.


# 1.176 02-Jul-2023 rillig

lint: use unsigned int for struct alignment

This gets rid of 'unsigned short', which saved a few bytes of memory but
was inconvenient to deal with.

No functional change.


# 1.175 02-Jul-2023 rillig

lint: clean up variable names


# 1.174 01-Jul-2023 rillig

lint: clean up comments in lint1.h


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.173 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.172 30-Jun-2023 rillig

lint: replace macro for unique identifiers with function

No functional change.


# 1.171 30-Jun-2023 rillig

lint: clean up handling of declarations

No functional change.


# 1.170 29-Jun-2023 rillig

lint: clean up member names of declaration levels

No functional change outside debug mode.


# 1.169 29-Jun-2023 rillig

lint: use standard terminology for bit-field width

No functional change.


# 1.168 29-Jun-2023 rillig

lint: enhance debug output for diagnostics

Only print the debug message if the diagnostic is active, which is
relevant for c99ism, c11ism and gnuism.

Print more details about the diagnostic or query.


# 1.167 24-Jun-2023 rillig

lint: reduce memory allocations

The type val_t has the same size as the tn_s member in the same union.

No functional change.


# 1.166 24-Jun-2023 rillig

lint: add query for comparing 'char' with plain integers


# 1.165 09-Jun-2023 rillig

lint: miscellaneous clean-ups

No binary change, except for line numbers in assertions.


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.164 22-Apr-2023 rillig

lint: rename type_t.t_str to t_sou

The name 't_str' could have meant 'string' or 'struct'. Since both
struct and union types have members, rename it to 't_sou'.

No functional change.


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.163 21-Feb-2023 rillig

lint: use __printflike


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.162 18-Feb-2023 rillig

lint: replace INTERNAL_ERROR with plain assert


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.161 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.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.160 14-Jan-2023 rillig

lint: use fewer abbreviations

No binary change except for line numbers in assertions in decl.c.


# 1.159 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.


Revision tags: netbsd-10-base
# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.158 01-Oct-2022 rillig

lint: add hyphen to adjective 'old-style'


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.157 28-Aug-2022 rillig

lint: rename dcs manipulation functions to be clearer

No functional change.


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.156 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.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.155 01-Jul-2022 rillig

lint: move error handling code from main1.c to err.c

No functional change.


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.154 26-May-2022 rillig

lint: rename olwarn and LWARN_BAD to be more expressive

No functional change.


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.153 16-Apr-2022 rillig

lint: investigate why lint only warns about some constant conditions

Noticed in lex.c, in the macro kwdef, where lint complains about the
condition containing '||' but not about the conditions containing only
'>' or '=='.


# 1.152 16-Apr-2022 rillig

lint: migrate gflag to allow_gcc

No functional change.


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.151 10-Apr-2022 rillig

lint: fix assertion failure on duplicate qualifiers from __typeof__


# 1.150 09-Apr-2022 rillig

lint: distinguish between storage class and declaration kind

These types overlap but are not the same.

No functional change.


# 1.149 09-Apr-2022 rillig

lint: rename dinfo_t.d_offset to d_offset_in_bits

Most often, offsets are measured in bytes, so better embed the unit in
the variable name.

No functional change.


# 1.148 09-Apr-2022 rillig

lint: extract is_member into separate function

No functional change.


# 1.147 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.146 09-Apr-2022 rillig

lint: split CTCONST into BOOL_CONST and ENUM_CONST

Having a unified compile-time constant "storage class" made the code
more difficult to understand.

No functional change.


# 1.145 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.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.144 02-Apr-2022 rillig

lint: use appropriate alignment on both the host and target platform


# 1.143 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.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.142 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.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.141 27-Feb-2022 rillig

lint: unabbreviate two more members of sym_t

No functional change.


# 1.140 27-Feb-2022 rillig

lint: remove unused enumeration details from symbol type

No functional change.


# 1.139 27-Feb-2022 rillig

lint: unabbreviate some fields in sym_t

No functional change.


# 1.138 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.137 27-Feb-2022 rillig

lint: clean up memory allocation

No functional change.


# 1.136 27-Feb-2022 rillig

lint: rename ARG to OLD_STYLE_ARG

Pre-C90 argument declarations have been old for more than 30 years now,
so mention that fact in the constant name. This reduces potential
confusion with other occurrences of the words 'arg' or 'argument'.

No functional change.


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.135 07-Feb-2022 rillig

lint: drop compatibility with C90

Since tools/README 1.5 from 2022-02-03, the tools no longer need to be
compatible with C90, they may now use C99 features. Lint had used
<stdbool.h> and snprintf already.

No functional change.


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.134 25-Dec-2021 rillig

lint: don't try to trick mathematics by defining ZERO to a nonzero value

No binary change.


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.133 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.132 22-Dec-2021 rillig

lint: remove spaces around bit-field colon

As seen in /usr/share/misc/style.

No binary change.


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.131 16-Nov-2021 rillig

lint: fix check for function calls in strict bool mode

Previously, if a function call occurred in the controlling expression,
its return type could be any scalar, not just bool. This was against
the goal of strict bool mode, which makes bool a separate and
incompabile type to all other types. For example, it would allow
controlling expressions like 'strcmp(a, b)' without the usual '!= 0',
but only if at least one of 'a' and 'b' came from a macro definition
from a system header.

The fix is that the decision of whether the type of the controlling
expression may be scalar is no longer based on the operand types but on
the main operator of the controlling expression.


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.130 01-Nov-2021 rillig

lint: enter full C90 compatibility mode

The C99 comment in tree.c:3468 has been there since 2017-03-06, without
anyone complaining that their compiler would not handle it.

Strangely, running GCC 10.3.0 in '-std=c90' mode does not complain about
declarations after statements, '-Wdeclaration-after-statement' is needed
separately.

No functional change.


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.129 14-Sep-2021 rillig

lint: allow [*] everywhere where [] and [integer] are allowed

It's a seldom used feature, but now it's at least consistent.


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.128 31-Aug-2021 rillig

lint: remove unused function for generic messages

The function message_at is still used, for information about previous
occurrences of a symbol.


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.127 28-Aug-2021 rillig

lint: fix a few lint warnings about type conversions

A simple 'unsigned int' is more than enough for representing the size of
a bit-field, as well as the maximum alignment of any type.

No functional change.


# 1.126 28-Aug-2021 rillig

lint: un-abbreviate unsigned integer types

No functional change.


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.125 23-Aug-2021 rillig

lint: expand macro in string concatenation

No functional change.


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.124 23-Aug-2021 rillig

lint: inline msb

This reduces the binary size on x86_64 by about 500 bytes.

No functional change.


# 1.123 22-Aug-2021 rillig

lint: merge duplicate code for binary operator

No functional change.


# 1.122 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.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.121 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.120 31-Jul-2021 rillig

lint: improve support for __int128_t and __uint128_t

For the .ln files, I chose the letter 'J' to represent the 128-bit
integer types since it is close to 'I' for int. The naming of 'L' for
'long' is obvious, but 'Q' for 64-bit integers is a quad-16-bit word,
which is an unusual measurement unit nowadays. One benefit of choosing
'J' is that the next letter, 'K' can then be used for 256-bit integer
types.

Support for 128-bit integer types is still very basic. Plus, it is only
supported on LP64 platforms, which means that lint cannot be
cross-compiled to check for an LP64 platform while running on an ILP32
platform.


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.119 31-Jul-2021 rillig

lint: merge duplicate code for generating unqualified type

This is a preparation for fixing the wrong warnings in msg_115.c.

No functional change.


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.118 23-Jul-2021 rillig

lint: rename cstk_t to control_statement

Rename the variables as well. Their previous name 'ci' was not easy to
understand, the 'i' may have meant 'stack item'. The new name 'cs'
simply means 'control statement'.

No functional change.


# 1.117 23-Jul-2021 rillig

lint: remove a few unnecessary abbreviations

No functional change.


# 1.116 23-Jul-2021 rillig

lint: make offset and alignment positive numbers

There's no use case for negative alignment or offsets in structures.

No functional change.


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.115 15-Jul-2021 rillig

lint: rename grammar rule 'declaration' to 'declaration_or_error'

This prepares for merging the duplicate code from top_level_declaration.
The code coverage outside cgram.y is exactly the same as before.

No functional change.


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.114 10-Jul-2021 rillig

lint: rename clrtyp/deftyp to begin_type/end_type

The abbreviations clr/def did not make it obvious that these two
functions or grammar rules form pairs.

No functional change.


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.113 08-Jul-2021 rillig

lint: constify keyword in lexer

No functional change.


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.112 06-Jul-2021 rillig

lint: rename type generic_association_types to generic_association

The word 'types' was misleading and unnecessary.

No functional change.


# 1.111 05-Jul-2021 rillig

lint: rename dinfo_t.d_stralign to d_sou_align_in_bits

When talking about alignment, offset and size of a type, the measurement
unit must be mentioned in the variable name, especially when it differs
from the standard unit of measurement, which is a byte, not a bit.

No functional change.


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.110 04-Jul-2021 rillig

lint: in strict bool mode, allow mixed types in generated C code

This allows flex lexers to be run through lint in strict bool mode.


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.109 02-Jul-2021 rillig

lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.108 28-Jun-2021 rillig

lint: rename pqinf_t to qual_ptr and clean up code

The 'inf' from the type name meant 'information' and was redundant. Each
object of that type represents a single pointer level, which made the
documentation about 'pointers' a bit confusing.

The members of struct qual_ptr are now in the canonical reading order,
which is 'const volatile pointer'.

No functional change.


# 1.107 27-Jun-2021 rillig

lint: fix result type of _Generic expressions


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.106 27-Jun-2021 rillig

lint: fix type of pqinf.p_pcnt

A counter that can either be 0 or 1 and is never incremented is not
really a counter, it's a flag.

No functional change.


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.105 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.104 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.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.103 19-Jun-2021 rillig

lint: replace undefined behavior with assertion failure

Triggered by this malformed code:

struct{int;


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.102 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
# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

branches: 1.100.2;
lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.101 15-May-2021 rillig

lint: warn about unreachable case labels for '&&'

See octeon_gmxreg.h 1.2 from 2020-06-18 for an example, where
RXN_RX_INBND_SPEED was cleaned up without adjusting the corresponding
code in octeon_gmx.c.


Revision tags: cjep_staticlib_x-base
# 1.100 18-Apr-2021 rillig

lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.100 18-Apr-2021 rillig

lint: remove redundant CONSTCOND

In do-while-0 loops, these are no longer needed since tree.c 1.202 from
2021-01-31.


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.99 18-Apr-2021 rillig

lint: rename parameter to diagnostic functions and macros

The first parameter is not just an arbitrary number, it's a message ID.


# 1.98 18-Apr-2021 rillig

lint: align the member access macros for tnode_t


# 1.97 18-Apr-2021 rillig

lint: add error_at, warning_at, message_at

Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

Make it easy for the code to migrate to the parameter-passing style.

No functional change.


# 1.96 18-Apr-2021 rillig

lint: document wrong location information in diagnostics


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.95 14-Apr-2021 rillig

lint: add support for C11-isms such as int[static 3]


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.94 10-Apr-2021 rillig

lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing. Exchange this confusion for 8 lines of
straight-forward preprocessing code.


# 1.93 10-Apr-2021 rillig

lint: prepare renaming of 'struct type'

It's confusing to have the same struct tag in both lint1 and lint2, with
mostly the same members, but also some differences. Before actually
changing this, I reviewed all occurrences of the word 'type' in the
code.

No functional change.


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.92 02-Apr-2021 rillig

lint: reduce memory usage

No functional change.


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.91 02-Apr-2021 rillig

lint: rename mbl to memory_block

No functional change.


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.90 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.89 26-Mar-2021 rillig

lint: rename members of struct control_statement to be more expressive

C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.

No functional change.


# 1.88 26-Mar-2021 rillig

lint: rename pushctrl and popctrl to be more expressive

While here, remove the magic number 0 that in this context means
"function body".

No functional change.


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.87 21-Mar-2021 rillig

lint: fix reachability for constant controlling expression in for loop


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.86 21-Mar-2021 rillig

lint: fix reachability computation in if statements

Previously, only loop statements were considered for reachability. This
ignored the possibility of an early return in an if statement, or
unreachable branches.


# 1.85 21-Mar-2021 rillig

lint: rename c_rchif to c_reached_end_of_then

No functional change.


# 1.84 21-Mar-2021 rillig

lint: rename c_cont to c_continue

No functional change.


# 1.83 21-Mar-2021 rillig

lint: document the precise meaning of control_statement.c_break

No functional change.


# 1.82 21-Mar-2021 rillig

lint: rename i_infinite to i_maybe_endless

Not every loop that has 'while (1)' is an endless loop. It may still
contain a 'return' somewhere.


# 1.81 21-Mar-2021 rillig

lint: fix wrong 'falls off bottom' after return in do-while


# 1.80 21-Mar-2021 rillig

lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated

No functional change.


# 1.79 21-Mar-2021 rillig

lint: rename d_nedecl to d_nonempty_decl

No functional change.


# 1.78 21-Mar-2021 rillig

lint: rename d_rdcsym to d_redeclared_symbol

No functional change.


# 1.77 21-Mar-2021 rillig

lint: rename clst to case_labels

No functional change.


# 1.76 20-Mar-2021 rillig

lint: document the struct for declarations more precisely

No functional change.


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.75 19-Mar-2021 rillig

lint: rename in_bit to in_bits

No functional change.


# 1.74 18-Mar-2021 rillig

lint: document the initialization of an object in more detail

This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.73 17-Mar-2021 rillig

lint: clean up documentation of dinfo_t

No functional change.


# 1.72 17-Mar-2021 rillig

lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


# 1.71 17-Mar-2021 rillig

lint: rename 'blklev' to 'block_level'

No functional change.


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.70 07-Mar-2021 rillig

lint: fix off-by-one error in 'case 3...5'

According to the GCC documentation[1], the high end of the range is
inclusive as well, which makes sense since otherwise there would be no
way of specifying a range that includes the maximum representable
number.

Since the range is not used at all in the code, none of the tests could
possibly fail.

[1] https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html

No functional change.


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.69 28-Feb-2021 rillig

lint: replace wrong comment with assertion

The broad type of a value is indeed stored in the value itself, in the
member v_tspec. For nodes that refer to this value, it is redundantly
stored, it always equals tn->tn_type->t_tspec.

After initialization, neither tn->tn_type nor val->v_tspec are modified.
This is not ensured by the compiler but has to be analyzed manually.

No functional change.


# 1.68 28-Feb-2021 rillig

lint: rename is_nonzero to constant_is_nonzero

The new function name emphasizes that the given node must have the
operator CON.

No functional change.


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.67 28-Feb-2021 rillig

lint: do not warn about constant expressions involving sizeof

These expressions are indeed constant for a specific platform, but on
another platform their value may change. This makes them unsuspicious
and legitimate for portable code.

Seen in rump_syscalls.c, as 'sizeof(int) > sizeof(register_t)'.


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.66 22-Feb-2021 rillig

lint: change spelling of initialisation to initialization

That's the wording from the ISO C99 standard.


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.65 19-Feb-2021 rillig

lint: rename storage class constants to be more expressive

No functional change.


# 1.64 19-Feb-2021 rillig

lint: rename t_isenum and t_aincompl to be more expressive

No functional change.


# 1.63 19-Feb-2021 rillig

lint: rename tenum_t and its members to be more expressive


# 1.62 19-Feb-2021 rillig

lint: rename str_t and its members to be more expressive

No functional change.


# 1.61 19-Feb-2021 rillig

lint: replace cryptic sym.s_rimpl with expressive name

No functional change.


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.60 23-Jan-2021 rillig

lint: fix two wrong error messages in strict bool mode

The strict bool mode gets complicated because for system headers the
rules need to be relaxed since they cannot be changed easily, often not at all.

Still, if lint validates a program in strict bool mode, that program
must run with equal behavior regarding boolean expressions even on a
pre-C99 platform.


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.59 18-Jan-2021 rillig

lint: clean up member names of control_structure and comments


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.58 17-Jan-2021 rillig

lint: extend a few message comments


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.57 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.56 16-Jan-2021 rillig

lint: in strict bool mode, integer constants do not have type bool

Previously, lint1 allowed integer constants such as 0 and 1 to be used
as bool constants. This was only half-baked since after fixing all
error messages from that strict mode, there may still be integer
literals in the code that should be replaced with true or false. This
would stop a migration from int to bool in the middle, leaving
inconsistent code around.

To find the remaining type inconsistencies, treat integers and bool as
completely incompatible, even for compile time constants.


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.55 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.54 15-Jan-2021 rillig

lint: merge duplicate code for non-zero detection


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.53 04-Jan-2021 rillig

lint: fix typos and other minor stylistic issues


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.52 03-Jan-2021 rillig

lint: rename cstk to cstmt

Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.

The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.


# 1.51 03-Jan-2021 rillig

lint: rename t_ispacked to t_packed and d_ispacked to d_packed

It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.


# 1.50 03-Jan-2021 rillig

lint: rename type.t_isfield to t_bitfield


# 1.49 03-Jan-2021 rillig

lint: in DEBUG mode, verify printf parameters for messages

Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.

By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.48 02-Jan-2021 rillig

lint: fix lint warning 161 "constant in conditional context"


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.47 02-Jan-2021 rillig

lint: use bool instead of u_int:1 in structures

Better late than never.


# 1.46 01-Jan-2021 rillig

lint: un-export struct istk


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.45 30-Dec-2020 rillig

lint: inline STRUCT_ASSIGN

This had only been necessary for some pre-C90 compilers.


# 1.44 30-Dec-2020 rillig

lint: un-abbreviate s_dpos, s_spos and s_upos


# 1.43 30-Dec-2020 rillig

lint: un-abbreviate s_field, s_keyw and s_xsym


# 1.42 30-Dec-2020 rillig

lint: un-abbreviate parenthesized and _strg


# 1.41 30-Dec-2020 rillig

lint: rename remaining _nxt members to _next


# 1.40 30-Dec-2020 rillig

lint: rename more _nxt members to _next


# 1.39 30-Dec-2020 rillig

lint: rename symt_t constants

There's no need to abbreviate them, furthermore FMOS was imprecise.


# 1.38 30-Dec-2020 rillig

lint: rename s_nxt to s_next


# 1.37 30-Dec-2020 rillig

lint: reduce verbosity of assertions

Having 2 lines of source code per assertion is too much, especially
since most of this code is redundant anyway. Extract the common code
and the additional negation into a simple function instead.


# 1.36 29-Dec-2020 rillig

lint: rename istk_t.i_cnt to i_remaining


# 1.35 29-Dec-2020 rillig

lint: fix typo in comments


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.34 29-Dec-2020 rillig

lint: fix indentation and alignment that used space-tab


# 1.33 29-Dec-2020 rillig

lint: spell check


# 1.32 28-Dec-2020 rillig

lint1: remove unused t_field


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

branches: 1.30.14;
teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.31 04-Mar-2019 christos

Add __thread/tls_model attribute


Revision tags: pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.30 27-Dec-2016 christos

teach lint __attribute__((__unused__))


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

branches: 1.29.6;
typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision


# 1.30 27-Dec-2016 christos

teach lint __attribute__((__unused__))


Revision tags: pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.29 20-Jul-2014 dholland

typo in comment


Revision tags: yamt-pagecache-base9
# 1.28 18-Apr-2014 christos

only fill memory with junk if BLKDEBUG


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.27 19-Apr-2013 christos

branches: 1.27.4;
Allow linted comments to take an argument that defines which error to suppress.


Revision tags: agc-symver-base
# 1.26 17-Feb-2013 christos

rename enum_t to avoid rpc/types.h lossage.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.25 24-Jun-2011 christos

branches: 1.25.2; 1.25.8;
Always use our own align macro and explain a bit more why this is bogus.


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.24 02-Oct-2009 christos

recognize struct __packed x { }; in addition to struct x { } __packed;


# 1.23 02-Oct-2009 christos

understand __attribute__((__packed__)) and __packed.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.22 10-Dec-2008 joerg

Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.21 01-May-2008 christos

fix const and volatile printing in types.


# 1.20 25-Apr-2008 christos

preliminary _Complex support.
NB: Does not really understand type conversions between complex and doubles.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking wrstuden-fixsa-base-1 netbsd-4-0-RELEASE cube-autoconf-base netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-armv6-base matt-mips64-base hpcarm-cleanup-base wrstuden-fixsa-base abandoned-netbsd-4-base netbsd-4-base chap-midi-nbase chap-midi-base
# 1.19 24-Sep-2005 perry

branches: 1.19.20;
in several comments:
implizit -> implicit
explizit -> explicit


# 1.18 17-Jul-2005 christos

Handle C99 array range initializers:

type a[] = { [lo ... hi] = c }:


# 1.17 07-Apr-2005 christos

Factor out tyname() so that it can be used both by lint1 and lint2.
Since type_t is different between lint1.h and lint2.h include the
appropriate file depending on the pass. Make the argument mismatch
error print the type names of the types involved. Now that we have
a tyname() function we can fix the rest of the pass2 warnings to be
more explanatory, but not now.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base fvdl_fs64_base
# 1.16 21-Oct-2002 christos

fix typo


# 1.15 21-Oct-2002 christos

support for c99 style and gnu style structure and union named initializers.


# 1.14 13-Sep-2002 christos

Minimize diffs with my C99 capable version [this commit does not include
C99 support.

- turn lerror() into a macro so that the filename and the line number of the
error are printed before we abort.
- recurse in type printing to provide the proper type name.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.13 05-Feb-2002 thorpej

Replace u_quad_t with uint64_t and quad_t with int64_t, and use
<inttypes.h> to get those type definitions. These types are more
portable, and a little more sane to do autoconf tests for.


# 1.12 31-Jan-2002 tv

Provide a placebo default for ALIGN() for hosts which don't have this.


# 1.11 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.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.10 14-Jun-2000 cgd

fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.


Revision tags: netbsd-1-4-PATCH003 minoura-xpg4dl-base netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.9 03-Nov-1997 cgd

branches: 1.9.8;
implement (hack in) symbol (function and variable) renaming, so that
the function renaming tricks currently needed by libc can be tolerated
by lint. This needs some cleanup, but it appears to work.


Revision tags: netbsd-1-3-base
# 1.8 27-Dec-1996 pk

branches: 1.8.2;
Splice a union in the type data structure. Some of the members can be `in use'
simultaneously, e.g. an enumerated bit-field.


# 1.7 22-Dec-1996 cgd

* recognize that pointers to identical unnamed and untyped structs,
unions, and enums are, in fact, identical. This is done by tagging
each of unnamed and untyped structure, union and enum with a unique
position of creation, which is used as a unique identifier that
when determine whether or not a pair of structures, unions, or enums
are identical.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.6 02-Oct-1995 jpo

don't print warnings about unused variables or arguments in compound
statements which contain asm statements.


# 1.5 02-Oct-1995 jpo

prototypes override old style function definitions
this is a gnu extension to ansi c


# 1.4 02-Oct-1995 jpo

added inline keywords
"inline" is enabled by -g, "__inline" and "__inline__" are always available


# 1.3 02-Oct-1995 jpo

prefixed members of dinfo_t with 'd_'


# 1.2 03-Jul-1995 cgd

RCS id cleanup


# 1.1 03-Jul-1995 cgd

branches: 1.1.1;
Initial revision